emacs-devel
[Top][All Lists]
Advanced

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

Re: macroexpand-all and cl-macrolet


From: Nic Ferrier
Subject: Re: macroexpand-all and cl-macrolet
Date: Mon, 19 Aug 2013 19:14:21 +0100

Wolfgang Jenkner <address@hidden> writes:

> On Sat, Aug 17 2013, Nic Ferrier wrote:
>
>> Is macroexpand-all not supposed to work with macrolet?
>>
>>   (progn
>>     (cl-macrolet 
>>         ((nlet (bindings &rest body)
>>            `(apply
>>              (lambda ,(mapcar 'car bindings) ,@body)
>>              (list ,@(mapcar 'cadr bindings)))))
>>       (macroexpand-all
>>        '(nlet ((a 1)
>>                (b '(10)))
>>          (* a (car b)))))) 
>>
>>    =>  (nlet ((a 1)
>>               (b (quote (10))))
>>          (* a (car b)))
>
> However, the following form evaluates to the desired expansion of nlet.
> It is inspired by the description of `macroexpand' in the CLHS, in
> particular by the remark about `macrolet' and the examples given there,
> see
>
> http://www.lispworks.com/documentation/HyperSpec/Body/f_mexp_.htm
>
> (progn
>   (require 'cl-lib)
>
>   (cl-defmacro macroexpand-all-locally (form &environment env)
>     `(macroexpand-all ,form ',env))
>
>   (cl-macrolet
>       ((nlet (bindings &rest body)
>            `(apply
>              (lambda ,(mapcar 'car bindings) ,@body)
>              (list ,@(mapcar 'cadr bindings)))))
>     (macroexpand-all-locally
>      '(nlet ((a 1)
>            (b '(10)))
>           (* a (car b))))))

That's brilliant Wolfgang, I don't understand it yet, but I have the
manual so I'll go find out.

Thanks again. 

PS, this is for an EmacsLisp->JavaScript compiler, so thanks for helping
to make such an abomination possible :-)


Nic



reply via email to

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