On Sun, Mar 11, 2007 at 01:13:13PM -0700, Per Bothner wrote:
> Scheme should allow expressions and declarations to be mixed in
> all bodies, not just top-level bodies.

I agree. I always tend to use macros that allow this, or if not, then
I just wrap everything inside a let* or letrec*.

There is a question of how this should be translated. If we have:

(let ()
  (define a (foo))
  (define b (bar))
  (baz)
  (define c (quux))
  (quuux))

Then should it be translated as

(let ()
  (letrec* ((a (foo))
            (b (bar)))
    (baz)
    (letrec* ((c (quux)))
      (quuux))))

or

(let ()
  (letrec* ((a (foo))
            (b (bar))
            (dummy (baz))
            (c (quux)))
    (quuux)))
?

The first way would allow redefining the same variable multiple times
in a body, but I'd prefer the latter alternative, so that all
expressions and definitions directly inside a body use the same
scope. Moreover, I think that a definition should be allowed as the
final element of a body. The body of the resulting letrec* expression
would then be (unspecified).


Lauri

_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to