GNU bug report logs - #17498
24.4.50; This function has a compiler macro `yes--cmacro'.

Previous Next

Package: emacs;

Reported by: Leo Liu <sdl.web <at> gmail.com>

Date: Thu, 15 May 2014 15:07:02 UTC

Severity: minor

Found in version 24.4.50

Done: Leo Liu <sdl.web <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 17498 in the body.
You can then email your comments to 17498 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to monnier <at> iro.umontreal.ca, bug-gnu-emacs <at> gnu.org:
bug#17498; Package emacs. (Thu, 15 May 2014 15:07:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Leo Liu <sdl.web <at> gmail.com>:
New bug report received and forwarded. Copy sent to monnier <at> iro.umontreal.ca, bug-gnu-emacs <at> gnu.org. (Thu, 15 May 2014 15:07:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.4.50; This function has a compiler macro `yes--cmacro'.
Date: Thu, 15 May 2014 23:05:18 +0800
Eval the following code

;;;; BEGIN
(defun yes ()
  )
(when nil
  (cl-define-compiler-macro yes (&rest _)))
;;;; END

,----[ C-h f yes RET ]
| yes is a Lisp function.
| 
| (yes)
| 
| This function has a compiler macro `yes--cmacro'.
| 
| Not documented.
| 
| [back]
`----

how is it possible? the compiler macro is defined at macro expansion
time?

Leo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17498; Package emacs. (Thu, 15 May 2014 19:46:01 GMT) Full text and rfc822 format available.

Message #8 received at 17498 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 17498 <at> debbugs.gnu.org
Subject: Re: bug#17498: 24.4.50;
 This function has a compiler macro `yes--cmacro'.
Date: Thu, 15 May 2014 15:43:11 -0400
> ;;;; BEGIN
> (defun yes ()
>   )
> (when nil
>   (cl-define-compiler-macro yes (&rest _)))
> ;;;; END

> ,----[ C-h f yes RET ]
> | yes is a Lisp function.
> | 
> | (yes)
> | 
> | This function has a compiler macro `yes--cmacro'.
> | 
> | Not documented.
> | 
> | [back]
> `----

> how is it possible? the compiler macro is defined at macro expansion
> time?

Pretty much, yes.  That's because the compiler macro is likely to be
needed/useful while compiling the rest of the file (before it gets
loaded).


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17498; Package emacs. (Fri, 16 May 2014 01:29:01 GMT) Full text and rfc822 format available.

Message #11 received at 17498 <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 17498 <at> debbugs.gnu.org
Subject: Re: bug#17498: 24.4.50;
 This function has a compiler macro `yes--cmacro'.
Date: Fri, 16 May 2014 09:28:06 +0800
On 2014-05-15 15:43 -0400, Stefan Monnier wrote:
> Pretty much, yes.  That's because the compiler macro is likely to be
> needed/useful while compiling the rest of the file (before it gets
> loaded).

But this is different from emacs 22 and 23. And it looks
counter-intuitive. I would expect macro expansion not to do much other
than transforming the code passed in. So I am curious is current
behaviour due to the byte-compiler i.e. if we don't do it this way it
won't work?

Thanks,
Leo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17498; Package emacs. (Fri, 16 May 2014 08:59:01 GMT) Full text and rfc822 format available.

Message #14 received at 17498 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Richard <theonewiththeevillook <at> yahoo.fr>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 17498 <at> debbugs.gnu.org
Subject: Re: bug#17498: 24.4.50;
 This function has a compiler macro `yes--cmacro'.
Date: Fri, 16 May 2014 10:59:41 +0200
Leo Liu <sdl.web <at> gmail.com> writes:

> Eval the following code
>
> ;;;; BEGIN
> (defun yes ()
>   )
> (when nil
>   (cl-define-compiler-macro yes (&rest _)))
> ;;;; END

FWIW (and because it was not obvious to me), it's due to
eval-and-compile:

(when nil
   (eval-and-compile (message "foo")))
=> foo is shown in *Messages*

Same with this :
(defmacro bar () '(eval-and-compile (message "foo")))
(when nil (bar))

This case could be "fixed" by optimizing `when' for a nil condition :

(defmacro new-when (cond &rest body)
  (declare (indent 1) (debug t))
  (and cond
       (list 'if cond (cons 'progn body))))

Then
(new-when nil (bar))
doesn't show anything.

-- 
Nico.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17498; Package emacs. (Fri, 16 May 2014 12:26:01 GMT) Full text and rfc822 format available.

Message #17 received at 17498 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Leo Liu <sdl.web <at> gmail.com>
Cc: 17498 <at> debbugs.gnu.org
Subject: Re: bug#17498: 24.4.50;
 This function has a compiler macro `yes--cmacro'.
Date: Fri, 16 May 2014 08:24:57 -0400
> But this is different from emacs 22 and 23. And it looks
> counter-intuitive. I would expect macro expansion not to do much other
> than transforming the code passed in. So I am curious is current
> behaviour due to the byte-compiler i.e. if we don't do it this way it
> won't work?

Well, there's always some other way, but yes it's made so that it works
when byte-compiling.


        Stefan




Reply sent to Leo Liu <sdl.web <at> gmail.com>:
You have taken responsibility. (Fri, 16 May 2014 18:27:01 GMT) Full text and rfc822 format available.

Notification sent to Leo Liu <sdl.web <at> gmail.com>:
bug acknowledged by developer. (Fri, 16 May 2014 18:27:02 GMT) Full text and rfc822 format available.

Message #22 received at 17498-done <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 17498-done <at> debbugs.gnu.org
Subject: Re: bug#17498: 24.4.50;
 This function has a compiler macro `yes--cmacro'.
Date: Sat, 17 May 2014 02:25:57 +0800
On 2014-05-16 08:24 -0400, Stefan Monnier wrote:
> Well, there's always some other way, but yes it's made so that it works
> when byte-compiling.

OK and thanks for the explanation. It took me by a surprise.

Leo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17498; Package emacs. (Fri, 16 May 2014 18:29:01 GMT) Full text and rfc822 format available.

Message #25 received at 17498 <at> debbugs.gnu.org (full text, mbox):

From: Leo Liu <sdl.web <at> gmail.com>
To: Nicolas Richard <theonewiththeevillook <at> yahoo.fr>
Cc: 17498 <at> debbugs.gnu.org
Subject: Re: bug#17498: 24.4.50;
 This function has a compiler macro `yes--cmacro'.
Date: Sat, 17 May 2014 02:28:32 +0800
On 2014-05-16 10:59 +0200, Nicolas Richard wrote:
> This case could be "fixed" by optimizing `when' for a nil condition

NIL is used to show the compiler macro is always defined; it could be
any non-constant expression. But thanks for pointing me to
eval-and-compile.

Leo




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 14 Jun 2014 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 13 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.