On Fri, Feb 11, 2011 at 11:42 AM, Christian Kellermann
<address@hidden> wrote:
* 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