unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Nicolas Richard <theonewiththeevillook@yahoo.fr>
To: Alexander Shukaev <haroogan@gmail.com>,
	 John Mastro <john.b.mastro@gmail.com>
Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Re: Macro Expansion Inconsistency
Date: Wed, 17 Dec 2014 15:21:18 +0100	[thread overview]
Message-ID: <5491915E.7080103@yahoo.fr> (raw)
In-Reply-To: <CAKu-7WyQ6UG_E7xkLvHcCJCW6Ey=uz1WBV5PSMw-jyy4gqAi_A@mail.gmail.com>

Le 17/12/2014 15:03, Alexander Shukaev a écrit :
> Thank you very much, John and Nicolas. I think I finally understand
> how macros expand in Emacs Lisp better now. I'm sure it's not a
> coincidence that you both came up with almost identical solutions. It
> suggests that the style of returning forms for evaluation from macro
> is probably the best way to go in most cases when `let' is involved.

I hadn't seen John's answer. His solution is better than mine because
the (put ...) forms should indeed be included in the progn. (otherwise
they get executed at expansion time, and I think that'll not be good if
the code is byte-compiled.)

> As a final exam for myself, considering what I've learned, I've implemented a collective definition macro as well:
> 
> (defmacro bm-define-flags
>     (name index character foreground &rest ...)
>   (let ((name       `,name)
>         (index      `,index)
>         (character  `,character)
>         (foreground `,foreground)
>         (...        `(,@...))

I think the above bindings are unnecessary.

>         (body       '()))
>     (while name
>       (push `(bm-define-flag ,name ,index ,character ,foreground) body)
>       (setq name       (pop ...)
>             index      (pop ...)
>             character  (pop ...)
>             foreground (pop ...)))
>     `(progn ,@body)))

Looks ok to me (but I'm not experienced).

> (put 'bm-define-flags 'lisp-indent-function 'defun)

I don't think that's useful for bm-define-flags. Btw you can also use a
(declare ...) form in your macro definition to achieve this goal.

-- 
Nicolas.




  parent reply	other threads:[~2014-12-17 14:21 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.16228.1418763453.1147.help-gnu-emacs@gnu.org>
2014-12-16 21:10 ` Macro Expansion Inconsistency Joost Kremers
2014-12-16 21:25   ` Alexander Shukaev
2014-12-16 21:46     ` John Mastro
2014-12-16 22:58       ` Alexander Shukaev
2014-12-16 23:14         ` Alexander Shukaev
2014-12-17  2:19           ` Alexander Shukaev
2014-12-17 10:04             ` Nicolas Richard
2014-12-17 14:03               ` Alexander Shukaev
2014-12-17 14:20                 ` Stefan Monnier
2014-12-17 14:34                   ` Alexander Shukaev
2014-12-17 14:21                 ` Nicolas Richard [this message]
2014-12-17 14:52                   ` Alexander Shukaev
2014-12-17 14:58                     ` Nicolas Richard
2014-12-17 15:14                       ` Alexander Shukaev
     [not found]               ` <mailman.16290.1418825041.1147.help-gnu-emacs@gnu.org>
2014-12-17 15:53                 ` Barry Margolin
2014-12-17 16:01                   ` Alexander Shukaev
     [not found]           ` <mailman.16262.1418782759.1147.help-gnu-emacs@gnu.org>
2014-12-17  3:03             ` Rusi
2014-12-17  9:21               ` Nicolas Richard
2014-12-16 23:20         ` John Mastro
     [not found]           ` <CAKu-7WzgoHH=zM_jxeVGMwzAne88nAoCUsLKQv9zUYo_amsjNg@mail.gmail.com>
2014-12-17  3:34             ` John Mastro
2014-12-17  3:41               ` John Mastro
2014-12-16 23:30   ` Stefan Monnier
2014-12-16 20:57 Alexander Shukaev

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=5491915E.7080103@yahoo.fr \
    --to=theonewiththeevillook@yahoo.fr \
    --cc=haroogan@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=john.b.mastro@gmail.com \
    /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.
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).