chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Recursive define-macro


From: Kon Lovett
Subject: Re: [Chicken-users] Recursive define-macro
Date: Wed, 7 Mar 2007 09:31:49 -0800

On Mar 7, 2007, at 12:37 AM, felix winkelmann wrote:

On 3/7/07, Joshua Griffith <address@hidden> wrote:
I get an unbound variable error when I execute the following:
(define-macro (test alist) (if (> 0 (length alist)) (test (cdr alist))))

I think this explains the above error:

#;1> rec
Error: unbound variable: rec
#;1> (macro? 'rec)
#t

A variable bound to a macro is not a regular variable.

If you need to recurse to perform macro expansion just use any of the syntax forms that help - named let, rec, repeat, do, etc.


Are recursive define-macro definitions possible?

The code inside a macro is executed at macro-expansion time,
and should probably not refer to itself for expansion. A macro
can be recursive by *expanding* into code that refers to the macro
(but that might end in endless recursion).

Yeah, using the macro expansion machinery to perform recursive expansion can work but tricky. A technique that might called "clever".



cheers,
felix


_______________________________________________
Chicken-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/chicken-users





reply via email to

[Prev in Thread] Current Thread [Next in Thread]