unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Achim Gratz <Stromeko@nexgo.de>
Cc: 14422@debbugs.gnu.org
Subject: bug#14422: 24.3; Eager Macro Expansion
Date: Thu, 30 May 2013 15:00:50 -0400	[thread overview]
Message-ID: <jwvzjvc482h.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87mwrcjqlu.fsf@Rainer.invalid> (Achim Gratz's message of "Thu, 30 May 2013 19:59:41 +0200")

> Here's the revised test case that compiles cleanly and still has the
> same problem:


> (defvar eme-ll nil)

> (defmacro one (p)
>   `(progn (push ',p eme-ll)))

> (defmacro two (p)
>   (let (pp)
>     (setq pp (append eme-ll p))
>   `(progn (push ',pp eme-ll))))

> (provide 'eme)


> (require 'eme)
> (require 'ert)

 
> (ert-deftest surprise ()
>     (should
>      (equal '((one . two) one)
> 	    (progn
> 	      (one one)
> 	      (two two)
> 	      eme-ll))))

I see the test fails, but that's just because the test is wrong.
Try to create a new file foo.el:

   (require 'eme)
   
   (message "Result = %s"
            (progn
   	      (one one)
   	      (two two)
   	      eme-ll))

Then byte-compile it.  Then do

   emacs23 --batch -Q -l ~/tmp/foo.el
and
   emacs23 --batch -Q -l ~/tmp/foo.elc

You'll see that your code behaves differently when byte-compiled.


        Stefan


Analysis:

  (one one)

will add `one' to eme-ll at run-time.

  (two two)

reads the macroexpansion-time (e.g. compilation-time, load-time, or
run-time) value of eme-ll and adds it to eme-ll at run-time.

  eme-ll

returns the run-time value of eme-ll.





  reply	other threads:[~2013-05-30 19:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-19 14:26 bug#14422: 24.3; Eager Macro Expansion Achim Gratz
2013-05-21  2:11 ` Stefan Monnier
2013-05-26 15:34   ` Achim Gratz
2013-05-26 19:29     ` Stefan Monnier
2013-05-26 19:57       ` Achim Gratz
2013-05-30 17:59   ` Achim Gratz
2013-05-30 19:00     ` Stefan Monnier [this message]
2013-05-30 19:38       ` Achim Gratz
2013-05-30 21:14         ` Stefan Monnier
2013-06-03 15:29           ` Stefan Monnier
2020-08-25 11:05             ` Lars Ingebrigtsen
2020-10-13  1:47               ` Lars Ingebrigtsen

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=jwvzjvc482h.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=14422@debbugs.gnu.org \
    --cc=Stromeko@nexgo.de \
    /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).