[plt-dev] syntax/module-reader and #%module-begin

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Mon Nov 30 13:32:52 EST 2009

On Mon, Nov 30, 2009 at 1:29 PM, Jay McCarthy <jay.mccarthy at gmail.com> wrote:
> On Mon, Nov 30, 2009 at 11:14 AM, Carl Eastlund <cce at ccs.neu.edu> wrote:
>> Modules have this weird property: they behave differently if they have
>> exactly one element in their body, than if they have zero elements, or
>> two or more elements.  They expand that body element looking for
>> #%module-begin.  If they have zero, or two or more, elements, they
>> wrap those elements in #%module-begin.  The #%module-begin form does
>> "most of the work" of expanding modules, so in the one-element-only
>> case, there is a period of expansion during which #%module-begin is
>> "not at the helm".  I bring this up because it caused a problem for
>> Stevie (resulted in a bug report about #lang scheme/signature, in the
>> case where a module contains precisely one form that is a use of
>> "contracted").
>>
>> Most of our #langs are written with syntax/module-reader, which reads
>> in a bunch of forms and wraps them in (module foo lang <FORM> ...).
>> The problem above would go away if instead it wrapped the forms in
>> (module foo lang (#%module-begin <FORM> ...)).  The only thing this
>> gives up is the ability to fill in a custom #%module-begin, but... who
>> does that, and why would one?
>
> I'm not sure I understand. But I have a custom #%module-begin that
> does expansion and compilation in the Web languages. I believe that TS
> does that too.

What I have proposed preserves custom #%module-begin.  It adds the one
from the module in question.  This is only about *when*, during the
expansion process, the language's #%module-begin gets added, not which
binding is used.

--Carl


Posted on the dev mailing list.