[plt-scheme] expression context and units

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue May 24 11:34:26 EDT 2005

At Tue, 24 May 2005 10:56:41 -0400, Jay McCarthy wrote:
> (unit/sig ()
>   (import servlet^)
>   (define test2 'test2)
>   (define-syntax foo2
>     (syntax-rules ()
>       [(_ bar)
>        (define bar (quote bar))]))
>   (foo2 xx))
> 
> ; define: not allowed in an expression context in: (define xx (quote xx))
> 
> So, at the top level, a (define-syntax) does not leave expression
> context, while in a unit it does, but only if the syntax has a define
> inside IT.

Macros defined within a unit body cannot expand to unit-level
definitions. Internal definitions have the same problem. It's because
expressions have to be partially expanded to find all the definitions
(including syntax definitions), and syntax definitions become available
only after this partial expansion.

I'd like to get rid of this constraint, but I don't yet know how to do
it in general.

Matthew



Posted on the users mailing list.