chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Implementing a macroexpand-all


From: Christian Kellermann
Subject: Re: [Chicken-users] Implementing a macroexpand-all
Date: Fri, 11 Feb 2011 17:42:48 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

* Patrick Li <address@hidden> [110211 17:20]:
> Hello everyone,
> 
> I'm trying to write a simple macroexpand-all function (a function to
> recursively macroexpand all subforms in a form until there are absolutely no
> macros left in the form), and realized that my naive implementation has a
> serious bug in it, namely that it doesn't keep track of local bindings
> within an expanded form.
> 
> Naive implementation:
> (define (macroexpand-all expression)
>   (let ((expanded (expand expression)))
>     (if (pair? expanded)
>         (map macroexpand-all expanded)
>         expanded)))
> 
> I want the function to obey this property:
> (eval some-expression) is *always* equivalent to (eval (macroexpand-all
> some-expression))
> 
> Is there an easy or existing way to do this? I have tried to write my own,
> but do not know which special forms actually introduce new bindings.

Are you aware of expand* from the expand-full egg?

Kind regards,

Christian




reply via email to

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