[Top][All Lists]

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

Re: macroexpand-all and cl-macrolet

From: Wolfgang Jenkner
Subject: Re: macroexpand-all and cl-macrolet
Date: Mon, 19 Aug 2013 14:08:13 +0200
User-agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux)

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,


  (require 'cl-lib)

  (cl-defmacro macroexpand-all-locally (form &environment env)
    `(macroexpand-all ,form ',env))

      ((nlet (bindings &rest body)
               (lambda ,(mapcar 'car bindings) ,@body)
               (list ,@(mapcar 'cadr bindings)))))
     '(nlet ((a 1)
             (b '(10)))
            (* a (car b))))))


reply via email to

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