[plt-scheme] Exposing non-exported module variable bindings.

From: Richard C. Cobbe (cobbe at ccs.neu.edu)
Date: Wed Dec 17 10:35:16 EST 2003

Lo, on Wednesday, December 17, Matthew Flatt did write:

> At Tue, 16 Dec 2003 21:31:55 -0500, "Richard C. Cobbe" wrote:
> > > (define-syntax module/expose
> > >   (syntax-rules ()
> > >     ((_ mod (id1 ...))
> > >      (begin
> > >        (require mod)
> > >        (define-values (id1 ...)
> > >          (let ([ns (module->namespace mod)])
> > >            (parameterize ([current-namespace ns])
> > >              (values 
> > >               (namespace-variable-value 'id1 #t void) ...))))))))
> > >   
> > > (module/expose "mod.scm" (a b)) ;; expose non-provided a and b bindings.
> > 
> > Unfortunately, this only seems to work if mod is a string; forms like
> > (lib "foo.ss" "bar") generate unbound identifier errors for lib.  Is
> > there an easy way to get this case to work as well?
> 
> I didn't actually try it, but I it looks like adding a quote in the
> template would be enough:
> 
>                        (module->namespace 'mod)

That seems to work for simple module specs, like the one I mentioned,
although I haven't tried anything more complex.  Thanks!

Richard


Posted on the users mailing list.