[plt-scheme] programmatic access to current namespace

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri May 1 08:22:38 EDT 2009

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


If the result is not #f, you can then extract the module name with

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

Posted on the users mailing list.