[plt-scheme] programmatic access to current namespace
At Fri, 01 May 2009 13:12:00 +0200, "Jose A. Ortega Ruiz" wrote:
> After enter!ing a module in mzscheme, calling (current-namespace) prints
> a representation of the current namespace that contains the module file
> name:
>
> > (enter! "/tmp/foo.ss")
> > (current-namespace)
> #<namespace:"/tmp/foo.ss":0>
> >
>
> Is there a way of getting the file name (or module path) a namespace
> refers to given the value of the latter? (i'm thinking of something
> like, say, (module-path (current-namespace)))
(variable-reference->resolved-module-path
(#%variable-reference))
If the result is not #f, you can then extract the module name with
`resolved-module-path-name'.
[I see that the docs say that the expression above will raise an
exception if the current namespace is a top-level namespace, instead
of a module namespace. In fact, I had changed it to produce #f in that
case, and I'll fix the docs.]