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

Re: (define <generated> ...)



>     (define-syntax defoo
>       (syntax-rules ()
> 	((defoo name)
> 	 (begin (define foo 30)
> 		(define name (+ foo 4))))))

>     (defoo x)

>     foo  =>  20 or 30 ?


> Of course, X will be 34 in either case.  But what I want to know is
> whether the identifier that gets defined by the macro's (define foo
> ...) is the generated identifier (alias) or FOO.

Bob and I discussed this at one point, but never decided what to do.
He observed that one gets a kind of module system if the binding is
hidden, i.e., to a generated variable.

> Oh, I forgot, DEFINE's for top-level variables might or might not
> introduce bindings, so maybe this is implementation-dependent?

Possibly.  If (define foo ...) were replaced with (set! foo ...), foo
should definitely be 30.  So it's probably most logical for
implementations that treat top-level defines as assignments not to
create a "hidden" variable.  I'm not sure about implementations in
which top-level defines create new bindings.

It's interesting to note that if the above sequence appears within a
lambda, foo has the value 20.  So if we want top-level definitions to
behave more like internal definitions...

Kent