[plt-scheme] namespaces and executables

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Aug 4 08:24:36 EDT 2006

At Fri, 4 Aug 2006 13:33:42 +0200 (CEST), Ivanyi Peter wrote:
> $ mzc --exe simulator.exe simulator.scm
> but then I have the full namespace of MzScheme with all
> macros and
> definitions, including mine. I came up with the following
> (define nn 
>   (let ([ns (null-environment 5)])
>     (parameterize ([current-namespace ns])
>       (namespace-require '(file "simulator.scm")))
>     ns))
> (current-namespace nn)
> which works and restricts the namespace, but in this case I have
> a file which is not a module so I cannot compile it into a
> self-standing
> executable.
> How can I combine the two together? How can I have my language
> with the limited namespace in a self-standing executbale?

You can use ++lib or ++collects to add modules to an executable that
are referenced dynamically (i.e., `dynamic-require' or
`namespace-require' instead of `require').

If you don't want to put the file in a collection (which is the
simplest way to have an absolute reference to a module), then use
`create-embedding-executable' from `(lib "embed.ss" "compiler")',
which gives you a lot more options than mzc --exe.


Posted on the users mailing list.