At Mon, 18 Mar 2019 19:32:40 -0400, Philip McGrath wrote:
> On Mon, Mar 18, 2019 at 9:14 AM Matthew Flatt <mfl...@cs.utah.edu> wrote:
> 
> > I wonder whether the solution is an extension of `scribble/lp2` to
> > support a `require-for-chunk` form where `chunk` records any such
> > imports in its context and adds then to the stitched-together program.
> >
> >  (require-for-chunk (only-in racket/string string-join))
> >
> >  (define-syntax-parser cross-phase-macro
> >    [(_ <>:id)
> >     @#`begin{@(func-not-exported)
> >
> >      @chunk[<>
> >             (string-join ....
> >
> > would work because `chunk` would pick up the `(only-in racket/string
> > string-join)` from its context and attach it to the chunk, so that
> > `(only-in racket/string string-join)` would be added to the
> > stitched-together context.
> >
> > Maybe this would work by having `require-for-chunk` expand to something
> > like `(begin-for-syntax (register-require #'chunk ....))` to register
> > in a compile-time free-id table mapping from the #'chunk identifier to
> > a list of imports. Then, the `chunk` macro would consult the table
> > using the identifier that invoked the macro. (I have not tried this to
> > be sure that it would work.)
> >
> 
> While thinking about this idea, I came up with a simpler example that
> exposes a hygiene issue in `scribble/lp2` without using `require`:
> 
> #lang scribble/lp2
> @(define-syntax-rule (chunk/define <> lhs rhs ...)
>    (chunk <>
>           (define hygiene "this shouldn't cause capture")
>           (define lhs rhs ...)))
> @(chunk <*> <a> <b>)
> @(chunk/define <a> a 1)
> @(chunk/define <b> b 2)
> 
> fails with the error "module: identifier already defined in: hygiene".

I can see why you might want this, but for what it's worth, I can also
see an argument against for `scribble/lp2`. If it did work, the typeset
output would be

 <*> ::=
     <a>
     <b>

 <a> ::=
     (define hygiene "this shouldn't cause capture")
     (define a 1)

 <b> ::=
     (define hygiene "this shouldn't cause capture")
     (define b 2)

which seems like nonsense. That is, there's not an extra dimension to
represent the macro-introduced scope in the textual output output, so
maybe it shouldn't be allowed.

Probably it's possible to make this work using delta introducers to
manipulate scopes, though.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to