[R6RS] Internal DEFINE vs. macros

Michael Sperber sperber
Fri Apr 15 11:02:17 EDT 2005


dyb at cs.indiana.edu writes:

>> > (let-syntax ((foo (syntax-rules ()
>> > 		    ((foo ?x) (define ?x 'outer)))))
>> >   (let ()
>> >     (define-syntax foo
>> >       (syntax-rules ()
>> > 	((foo) (define ?x 'inner))))
>> >     (foo a)
>> >     a))
>> >
>> >> produces outer on PLT, but on Chez says:
>> >>
>> >> Error: invalid syntax (foo a).
>> >>
>> >> Why?  (If you think I should wait until the full description of
>> >> SYNTAX-CASE is out let me know.)
>> >
>> > Chez Scheme processes body forms from left to right and adds macro
>> > definitions to the compile-time environment as it proceeds. [...]
>>
>> I'm probably being dense---why doesn't the definition of FOO get
>> applied to the use then?  Why is this an error?
>
> Yes, you are being dense ;-).  The inner foo's pattern matches (foo),
> i.e., zero subforms, and the macro call is (foo a), with one subform.

Good thing I have an R6RS editor at my disposal to proofread my code!
(That's usually Matthew's job. :-) )  Thanks!

-- 
Cheers =8-} Mike
Friede, V?lkerverst?ndigung und ?berhaupt blabla


More information about the R6RS mailing list