[r6rs-discuss] Expansion process

From: Per Bothner <per>
Date: Thu Feb 22 15:16:43 2007

When expanding a body, the specification says that the RHS of a
define is deferred. An alternative would be to defer the
expansion of *lambda* forms instead. That to me seems more
natural.

- It seems wrong that
   (define VAR EXP)
would defer expanding EXP, while
   (set! VAR EXP)
expands EXP immediately.
Note: This is relevant if we're expanding a <toplevel body> -
*or* this proposal is accepted:
http://lists.r6rs.org/pipermail/r6rs-discuss/2007-January/001333.html

- Is there any benefit to deferring expanding RHS *other than*
lambda forms? It does allow:
   (define VAR (some-macro ARGS))
   (define-syntax some-macros ...)
but I don't think that is very useful.

- Deferring lambdas rather than define allows repls and load to
work more consistently. Consider:
   (define FUN (lambda () (MAC)))
   (define-syntax MAC ...)
This is required to work by the existing specification. But now
consider what happens if you type this into a repl, or load it
from a file. In that case evaluation is line-by-line. In that
case the pair of definitions above break, because we cannot
defer expanding the RHS of the define. However, we can defer
expanding a lambda until it is actually called. If we use that
model, then the above can work in a repl just like it does
in a nested body.

- Another place where there is a difference:
   (define VAR (let ((LOCAL ...)) (lambda () (MAC ...))))
   (define-syntax MAC ...)
This would not work under my proposal. We must expand the lambda
in its local context. Thus while expanding it is deferred, it is
only deferred until the end of processing the body of the let.
-- 
	--Per Bothner
per_at_bothner.com   http://per.bothner.com/
Received on Thu Feb 22 2007 - 15:18:13 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC