all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nic Ferrier <nferrier@ferrier.me.uk>
To: emacs-devel@gnu.org
Subject: Re: macroexpand-all and cl-macrolet
Date: Mon, 19 Aug 2013 19:14:21 +0100	[thread overview]
Message-ID: <87r4dp1rb6.fsf@ferrier.me.uk> (raw)
In-Reply-To: <85wqnhq3wy.fsf@inode.at> (Wolfgang Jenkner's message of "Mon, 19 Aug 2013 14:08:13 +0200")

Wolfgang Jenkner <wjenkner@inode.at> 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	other threads:[~2013-08-19 18:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-17 19:25 macroexpand-all and cl-macrolet Nic Ferrier
2013-08-19  2:51 ` Stefan Monnier
2013-08-19 12:08 ` Wolfgang Jenkner
2013-08-19 18:14   ` Nic Ferrier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r4dp1rb6.fsf@ferrier.me.uk \
    --to=nferrier@ferrier.me.uk \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.