[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Macro Expansion Inconsistency
From: |
Nicolas Richard |
Subject: |
Re: Macro Expansion Inconsistency |
Date: |
Wed, 17 Dec 2014 15:21:18 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 |
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.
- Re: Macro Expansion Inconsistency, (continued)
- Re: Macro Expansion Inconsistency, Joost Kremers, 2014/12/16
- Re: Macro Expansion Inconsistency, Alexander Shukaev, 2014/12/16
- Re: Macro Expansion Inconsistency, John Mastro, 2014/12/16
- Re: Macro Expansion Inconsistency, Alexander Shukaev, 2014/12/16
- Re: Macro Expansion Inconsistency, Alexander Shukaev, 2014/12/16
- Re: Macro Expansion Inconsistency, Alexander Shukaev, 2014/12/16
- Re: Macro Expansion Inconsistency, Nicolas Richard, 2014/12/17
- Re: Macro Expansion Inconsistency, Alexander Shukaev, 2014/12/17
- Re: Macro Expansion Inconsistency, Stefan Monnier, 2014/12/17
- Re: Macro Expansion Inconsistency, Alexander Shukaev, 2014/12/17
- Re: Macro Expansion Inconsistency,
Nicolas Richard <=
- Re: Macro Expansion Inconsistency, Alexander Shukaev, 2014/12/17
- Re: Macro Expansion Inconsistency, Nicolas Richard, 2014/12/17
- Re: Macro Expansion Inconsistency, Alexander Shukaev, 2014/12/17
- Message not available
- Re: Macro Expansion Inconsistency, Barry Margolin, 2014/12/17
- Re: Macro Expansion Inconsistency, Alexander Shukaev, 2014/12/17
- Message not available
- Re: Macro Expansion Inconsistency, Rusi, 2014/12/16
- Re: Macro Expansion Inconsistency, Nicolas Richard, 2014/12/17
- Re: Macro Expansion Inconsistency, John Mastro, 2014/12/16
- Message not available
- Re: Macro Expansion Inconsistency, John Mastro, 2014/12/16
- Re: Macro Expansion Inconsistency, John Mastro, 2014/12/16