[plt-dev] syntax/module-reader and #%module-begin
On Dec 1, Sam TH wrote:
> 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?
Yes.
> 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.
It is already a special case -- it's a symbolic name that gets added.
(IIRC, `#%plain-module-begin' is not a special case, and intended only
to be provided from a language as `#%module-begin'.)
The reason I've asked this is that a reader that adds `#%module-begin'
will be broken if it's added by `syntax/module-reader'
unconditionally.
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!