[racket-dev] `#%declare' and cross-phase persistent modules

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Jul 22 12:18:58 EDT 2013

As of v5.90.0.2 (pending), to declare a cross-phase persistent module,
the module body must include

 (#%declare #:cross-phase-persistent)

If the module declaration fails to meet the syntactic and import
constraints of a cross-phase persistent module, then a syntax error is
reported.

This change is backward-incompatible in two ways:

 * Module declarations that are intended as cross-phase persistent
   won't be, anymore, until a `#%declare' form is added.

   I think cross-phase persistence is new enough --- and the old, quiet
   inference of persistence is sufficiently distressing --- that this
   won't be much of an issue.

 * The grammar of fully-expanded modules now includes `#%declare'
   forms.

   Programs that process fully-expanded modules are not common, but I
   expect that they exist outside of the main distribution. Those
   programs will need to be updated. Meanwhile, they won't break until
   they see a module that has a `#%declare' form, which won't happen
   often (at least for the near future).

Although `#:cross-phase-persistent' is the only keyword recognized by
`#%declare' initially, we'll add more. One possibility is a declaration
that corresponds to `compile-enforce-module-constants'.

I named the form `#%declare' instead of `declare' to avoid conflicts,
and also because I expect the form to be used more often in macro
expansions than directly, so it seems like a "#%" kind of form.


Posted on the dev mailing list.