[racket-dev] internal-definition parsing

From: Eli Barzilay (eli at barzilay.org)
Date: Wed Jul 7 17:55:33 EDT 2010

On Jul  7, Matthew Flatt wrote:
> Short version:
> I'm planning to change internal-definition expansion (anywhere that
> says `body ...' in the Racket documentation) to allow expressions to
> mingle with definitions. For example,
> [...]


On Jul  7, Matthias Felleisen wrote:
> 4. I am vaguely interested in #%body because I have a hunch that
>    there are yet more possibilities. But at the same time, I
>    understand your objection and I can only see a limited utility of
>    #%body now. (That doesn't mean much, because I originally failed
>    to appreciate #%module-begin.)

I have a very conceret interest in that.  Is there any concrete
example for something that would go wrong with it now?

What bugs me often is that playing around with a different semantics
for body sequences is currently very tedious -- I have to redefine
`lambda', `let', `define', and their (many) relatives (even things
like `for' etc, if it should be complete), and in practice it always
ends up being a half-assed job instead...

Some examples that show how useful this is:

  * In the lazy language you want the implicit begin to force all
    expressions except for the last one.

  * I've redefined the implicit begin (in an ugly way) for my course
    language to force all non-tail expressions to have a `Void' type.

  * The scribble/text language should really return a list of all
    values instead of just the last one.  It currently provides `text'
    that builds on `begin/collect', which allows each block of
    consecutive definitions to be mutually recursive -- this is now a
    problem in that it's different in a subtle way than the default
    implicit begin.

I think that a good goal is to have all of these uses available as
simple macro definitions.

If you take the lazy use as an example, then just a single `#%body'
thing is not enough: since it needs to force only expressions, then
having a `#%body' means that it will need to do its own crawling over
the expressions to find which ones are not definitions and force
them.  So it looks like another special #% macro would be needed, and
even that is not enough to implement the last one conveniently, since
it needs to collect all non-definition expressions and combine them.

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

Posted on the dev mailing list.