[CM] Snd 10.8
Kjetil S. Matheussen
k.s.matheussen at notam02.no
Sun Aug 9 07:40:33 PDT 2009
On Sun, 9 Aug 2009, Kjetil S. Matheussen wrote:
>
>
> On Sun, 9 Aug 2009, Heinrich Taube wrote:
>
>> Im expecting to see the "expanding foo macro!" message only one time.
>> but maybe im confused!
>> that is i thought the macro got expanded when 'define' did its work,
>> not when i call the function.
>>
>> (define-macro (foo . args)
>> (format #t "expanding foo macro!~%")
>> `(list , at args))
>>
>> (define (usefoo a b c)
>> (foo a b c))
>>
>> cm> (usefoo 1 2 3)
>> expanding foo macro!
>> (1 2 3)
>> cm> (usefoo 1 2 3)
>> expanding foo macro!
>> (1 2 3)
>> cm> (usefoo 1 2 3)
>> expanding foo macro!
>> (1 2 3)
>> cm>
>>
>
> I'm pretty sure this is the common behavior for lisp interpreters.
Sorry, that's probably not true.
Guile only expands the first time. (even doing it twice, looks like...)
guile> (define-macro (foo . args) (display "expanding")(newline) `(list , at args))
guile> (define (usefoo a b c)(foo a b c))
guile> (usefoo 1 2 3)
expanding
expanding
(1 2 3)
guile> (usefoo 1 2 3)
(1 2 3)
guile> (usefoo 1 2 3)
(1 2 3)
More information about the Cmdist
mailing list