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

Re: [Scheme-reports] Rebinding syntactic keywords as variables

On Sun, 24 Apr 2011 15:47:39 -0400, Andre van Tonder <andre@x>  

> (define else 1)
> (define-syntax cond .......)
> (define else 2)  ; this is just a set! so does not change the location to
>                   ; which ELSE is bound
> (cond (else "matches else"))  ==> matches else

> but the following isn't well-defined

> (define-syntax else .......)
> (define-syntax cond .......)
> (define else 2)  ; not just a set! any more
> (cond (else "matches else"))  ==> does this match ELSE or not?

To put a data point out here, Chez Scheme matches the else in the second  
example, so the redefinition of a syntactic transformer to a regular  
binding is just an assignment.

I think this can be attributed to a single environment for both syntax and  
regular definitions (I do not know if this is the actual way in which Chez  
Scheme does this, but it *acts* that way to an user). In Chez Scheme you  
cannot have two else bindings, one for syntax and one for regular values.  
On the other hand, I think Scheme48 and some other Schemes do in fact  
allow you to have multiple environments for each evaluation "phase," so it  
is possible to have an else in the syntactic environment and another in  
the runtime environment. I do not know how this might affect the above.

	Aaron W. Hsu

Programming is just another word for the lost art of thinking.

Scheme-reports mailing list