[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
macros expanding into definitions
Posted-Date: Tue, 01 Dec 92 13:43:03 EST
Date: Tue, 01 Dec 92 13:43:03 EST
From: John D. Ramsdell <ramsdell@linus.mitre.org>
> Personally, I would favor a semantics for internal definitions that is
> closer to toplevel definitions:
>
> 1) Definitions are evaluated in order.
> 2) They can be intermixed with non-definitions.
> 3) A redefinition of a variable is legal and equivalent to a set!
I don't particularly object to this, but there are cases that have not
been specified, namely
(define a 23)
(define (foo)
(write a)
(define a 44)
(write a))
(foo)
Do you get an error for the first write?
Does it print 23?
A more complex example:
(define a 23)
(define (foo)
(set! a 56)
(write a)
(define a 44)
(write a))
(begin (foo) (write a))
Is the assignment in error?
Does the last write print 56 or 23?
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)
while the second would be rewritten as
(define a 23)
(define (foo)
(let ((a <unspecified>))
(set! a 56)
(write a)
(set! a 44)
(write a)))
(begin (foo) (write a))