Re: [racket-users] Lexical context for all-defined-out

2017-04-26 Thread Philip McGrath
Thanks, that does the trick!

-Philip

On Wed, Apr 26, 2017 at 6:27 PM, Matthew Flatt  wrote:

> The `all-defined-out` macro supports a trick that several non-hygienic
> macros use: it uses the scopes on the parentheses around
> `all-defined-out` non-hygienically, instead of the scopes on the
> identifier.
>
> So, in place of
>
>  (datum->syntax stx '(all-defined-out)))
>
> you can use
>
>  (datum->syntax stx `(,#'all-defined-out)))
>
> and then you don't have to export `all-defined-out`.
>
> At Wed, 26 Apr 2017 18:01:00 -0500, Philip McGrath wrote:
> > I'm working on a #%module-begin variant that provides all module-level
> > bindings, and I'm having trouble finding the right way to give lexical
> > context to all-defined-out.
> >
> > The issue (IIUC) is that all-defined-out only exports identifiers "that
> > have the same lexical context as the (all-defined-out) form"; however, I
> > want to have #%module-begin introduce all-defined-out, but have it export
> > the identifiers defined by the programmer in the body of the module.
> >
> > Currently what I'm doing is essentially this:
> >
> > #lang racket
> >
> > (module lang racket
> >   (provide (except-out (all-from-out racket)
> >#%module-begin
> >provide
> >;all-defined-out ;can't omit this
> >)
> >(rename-out [providing-module-begin
> > #%module-begin]))
> >   (require (for-syntax syntax/parse))
> >   (define-syntax (providing-module-begin stx)
> > (syntax-parse stx
> >   [(_ body:expr ...)
> >#`(#%module-begin
> >   (provide #,(datum->syntax stx '(all-defined-out)))
> >   body ...)])))
> >
> > (module demo (submod ".." lang)
> >   (define something
> > "a value"))
> >
> > (require (submod "." demo))
> >
> > something
> >
> >
> > This almost works — the providing happens correctly — but it requires
> that
> > the lang module provide all-defined-out, which I don't actually want to
> be
> > otherwise available.
> >
> > Is there a way to give all-defined-out the lexical context I'm looking
> for?
> >
> > --
> > 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.
>
> --
> 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.
>

-- 
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.


Re: [racket-users] Lexical context for all-defined-out

2017-04-26 Thread Matthew Flatt
The `all-defined-out` macro supports a trick that several non-hygienic
macros use: it uses the scopes on the parentheses around
`all-defined-out` non-hygienically, instead of the scopes on the
identifier.

So, in place of

 (datum->syntax stx '(all-defined-out)))

you can use

 (datum->syntax stx `(,#'all-defined-out)))

and then you don't have to export `all-defined-out`.

At Wed, 26 Apr 2017 18:01:00 -0500, Philip McGrath wrote:
> I'm working on a #%module-begin variant that provides all module-level
> bindings, and I'm having trouble finding the right way to give lexical
> context to all-defined-out.
> 
> The issue (IIUC) is that all-defined-out only exports identifiers "that
> have the same lexical context as the (all-defined-out) form"; however, I
> want to have #%module-begin introduce all-defined-out, but have it export
> the identifiers defined by the programmer in the body of the module.
> 
> Currently what I'm doing is essentially this:
> 
> #lang racket
> 
> (module lang racket
>   (provide (except-out (all-from-out racket)
>#%module-begin
>provide
>;all-defined-out ;can't omit this
>)
>(rename-out [providing-module-begin
> #%module-begin]))
>   (require (for-syntax syntax/parse))
>   (define-syntax (providing-module-begin stx)
> (syntax-parse stx
>   [(_ body:expr ...)
>#`(#%module-begin
>   (provide #,(datum->syntax stx '(all-defined-out)))
>   body ...)])))
> 
> (module demo (submod ".." lang)
>   (define something
> "a value"))
> 
> (require (submod "." demo))
> 
> something
> 
> 
> This almost works — the providing happens correctly — but it requires that
> the lang module provide all-defined-out, which I don't actually want to be
> otherwise available.
> 
> Is there a way to give all-defined-out the lexical context I'm looking for?
> 
> -- 
> 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.

-- 
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.