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

From: Sam TH (samth at ccs.neu.edu)
Date: Tue Dec 1 11:20:32 EST 2009

On Tue, Dec 1, 2009 at 10:59 AM, Eli Barzilay <eli at barzilay.org> wrote:
> On Nov 30, Stevie Strickland wrote:
>>
>> I've tried making the following change (surrounded by -----):
>>
>> -----
>> Index: collects/syntax/module-reader.ss
>> ===================================================================
>> --- collects/syntax/module-reader.ss  (revision 17113)
>> +++ collects/syntax/module-reader.ss  (working copy)
>> @@ -170,7 +170,11 @@
>>                                          (- (or (syntax-position modpath) (add1 pos))
>>                                             pos)))
>>                            v))]
>> -           [r `(,(tag-src 'module) ,(tag-src name) ,lang . ,body)])
>> +           [wrapped-body (let ([wrapped `(#%module-begin . ,body)])
>> +                           (if stx?
>> +                               (datum->syntax #f wrapped all-loc)
>> +                               wrapped))]
>> +           [r `(,(tag-src 'module) ,(tag-src name) ,lang ,wrapped-body)])
>>        (if stx? (datum->syntax #f r all-loc) r)))
>>
>>    (define (wrap lang port read modpath src line col pos)
>> -----
>
> Isn't it better to do the wrapping only when `#%module-begin' is not
> there?

What would this mean?  Looking for the symbolic name '#%module-begin?
That seems like it adds another special case, where the benefit of the
change is to remove such special cases, especially since it wouldn't
help if you wrote #%plain-module-begin instead.

-- 
sam th
samth at ccs.neu.edu


Posted on the dev mailing list.