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

From: Eli Barzilay (eli at barzilay.org)
Date: Tue Dec 1 10:59:49 EST 2009

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?


> But the other failure happens only during setup-plt (as far as I can
> tell) with files that use "#lang scribble/lp".  [...]
> I've looked at the expansion of these files via the macro debugger
> on a clean checkout, and that does seem to be what they expand to
> when they successfully run, so I'm not sure what's going on here.
> It confuses me that these run fine, and I can compile them with mzc,
> but they fail to compile during setup-plt.  Is there something I'm
> overlooking?

Yes -- the file that fails is "games/scribblings/chat-noir.scrbl", and
if you look at "scribble/lp-include.ss" you'll see why it fails.  (And
it's an easy fix, either by including a similarly bogus definition for
`#%module-begin' or the better solution of using the reader variant of
include and strip off the wrapper.)

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the dev mailing list.