unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Wolfgang Jenkner <wjenkner@inode.at>
To: Nic Ferrier <nferrier@ferrier.me.uk>
Cc: emacs-devel@gnu.org
Subject: Re: macroexpand-all and cl-macrolet
Date: Mon, 19 Aug 2013 14:08:13 +0200	[thread overview]
Message-ID: <85wqnhq3wy.fsf@inode.at> (raw)
In-Reply-To: 87wqnk15nl.fsf@ferrier.me.uk

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))))))


Wolfgang



  parent reply	other threads:[~2013-08-19 12:08 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 [this message]
2013-08-19 18:14   ` Nic Ferrier

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=85wqnhq3wy.fsf@inode.at \
    --to=wjenkner@inode.at \
    --cc=emacs-devel@gnu.org \
    --cc=nferrier@ferrier.me.uk \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).