[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

macros expanding into definitions



> Personally I prefer that the first example be in error and the second
> print 23 at the end, since, to me, the first would be rewritten as
> 
>     (define a 23)
> 
>     (define (foo)
>       (let ((a <unspecified>))
>         (write a)
>         (set! a 44)
>         (write a)))
> 
>     (foo)

This was my understanding also.  That is:

1) All internally defined variables are put in an implicit let at the head
of the corresponding body.
2) The initial binding is to an unspecified value.
3) The internal defines are simply replaced with set!'s.

In addition, the report should say that it is an error to reference or
set! a variable before the definition has been evaluated.  The
following is thus an error:

(define (foo)
  (define (bar) (set! x 5))
  (bar)
  (define x 0)
  x)

Marc