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 ,@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 ,@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) _______________________________________________ Cmdist mailing list [email protected] http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist
