[plt-scheme] Defining a transformation time path, or setting module-language to something useful

From: Eli Barzilay (eli at barzilay.org)
Date: Wed Jun 24 12:17:51 EDT 2009

On Jun 24, Noel Welsh wrote:
> I'm trying to set the module-language syntax property so I can
> recognise imports in a particular language. [...]

The intention of this property is to provide properties about the
language, not about the actual module code.

In any case:

* The plan is to make it easy to get `syntax/module-reader' to do the
  right thing for you.

* If you use it (syntax/module-reader) now, and put your own property,
  then one of you will win and the other will lose the propery.
  Either way, things will break.

* The version in svn is already working, but not documented yet (since
  I'm not done with hacking it, or figuring out if it's fine in its
  current form).  To use it, you add something like:

    (lambda (key default)
      (case key
        [(my-sym) <something>]
        [else default]))

  where `default' is a function that can also be applied on the key to
  return the default value.

* The default doesn't matter much for now, since there are no keys
  that are decided, but you should make it be some symbol that is
  private to you (for example, using `module-imports' is a bad idea).

* The `<something>' there should be determined completely by the
  `#lang' line, not by the source.  This is because all of this should
  work in the same way as `read-language'.  That is, the same
  information should be returned either way.  If it doesn't, then your
  langauge will likely be broken in some ways.  If this is really what
  you need, then I can say how to get the information from the `#lang'
  line needed for this `<something>'

> [...] So how do I create a useful value to place within the
> property? Do I just hardcode it?

In case you really want to do it, you can see the source.  The short
version is that you place the property when you read the module, and
the reader functions get the reader module path as an argument, which
can be used for the property.  (If you do use `syntax/module-reader'
then you don't have access to this argument, but I didn't see any
reason to use it yet.)

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.