[plt-scheme] Using 'lang' with relative paths in mzscheme 3.99?

From: Doug Orleans (dougorleans at gmail.com)
Date: Fri Feb 1 21:37:34 EST 2008

On Feb 1, 2008 7:13 PM, Danny Yoo <dyoo at cs.wpi.edu> wrote:
>
>
> > Why do you want quotemarks instead of just
> >
> >  #lang mylanguage
>
> Under the default module name resolver, 'mylanguage' would have to be in
> the collects directory.  However, I have a 'mylanguage.ss' in the same
> directory as the module I'm defining, and I want to be able to use a
> relative module path.

Here are the docs for #lang from the PLT Reference (13.6.16):

  The #lang reader form is similar, but more constrained: the #lang
  must be followed by a single space (ASCII 32), and then a non-empty
  sequence of alphanumeric ASCII, +, -, _, and/or / characters
  terminated by whitespace or an end-of-file. The sequence must not
  start or end with /. A sequence #lang <name> is equivalent to
  #reader <name>/lang/reader.

So the "#lang" shortcut doesn't name a language module directly, it
names a reader module, which itself must provide something that
expands into the appopriate "(module ...)" form.  Look at some
standard lang/reader modules (e.g. scheme/base/lang/reader.ss): they
use the syntax/module-reader language to do this.  So, put the
following into ./lang/reader.ss:

  (module reader syntax/module-reader
    "mylanguage.ss")

Then, assuming that your collection is in the collects path, you can
use:

  #lang mycollect

where 'mycollect' is the name of your collection (i.e. the current
directory).


> As another way of posing the question: can I use #lang where the language
> is defined in a PLaneT package?

I think you can just replace "mylanguage.ss" above in the reader
module with the appropriate "(planet ...)" form.


--dougorleans at gmail.com


Posted on the users mailing list.