[plt-scheme] 299.107

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Jun 28 13:08:18 EDT 2005

MzScheme and MrEd are now version 299.107 in the SVN repository trunk.

The main change is that internal macro definitions are available for
expanding later definitions in the same internal-definition sequence:

 (let ()
   (define (get-five) five)
   (define-syntax define-five
     (syntax-rules ()
       [(_ id) (define id 5)]))
   (define-five five)
  
   (get-five)) ; => 5

This change makes the implementation of `define-struct' much simpler.
Previously, to support expressions like

 (let ()
   (define-struct a ())
   (define-struct (b a) ())
   ....)

the `define-struct' macro had to specially expand in an
internal-definition context to delay the lookup of `a' for implementing
the structure type `b'. This special handling is no longer needed,
because the for-syntax definition of `a' has been evaluated by the time
that the second `define-struct' is expanded.

Some other macros should work better for the same reason. Also, the new
handling of local macro definitions should make MzScheme behave more
like Chez (and, presumably, the portable `syntax-case' expander).


The cost of the change is an additional burden on macros like `class',
`unit', and `begin-with-definitions', all of which implement new
internal-definition contexts. They must use the new expansion-time
functions `syntax-local-make-definition-context' and
`syntax-local-bind-syntaxes'; calls to the latter must be interleaved
with partial expansion via `local-expand', and it's somewhat painful.
Probably, we can abstract out the pattern into a library. Possibly, I'm
the only one who writes such macros, anyway. :)

Since `unit' does uses the new functions, macros defined within a unit
body can now expand to unit-level definitions. In particular, the code
that Jay wanted to write last month now works (see
http://list.cs.brown.edu/pipermail/plt-scheme/2005-May/008902.html).


Matthew



Posted on the users mailing list.