emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A combination of defmacro, functionp, and quoted lambdas yields diff


From: Clément Pit-Claudel
Subject: Re: A combination of defmacro, functionp, and quoted lambdas yields different results on consecutive evaluations
Date: Sun, 25 Feb 2018 13:09:51 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 2018-02-18 13:02, Stefan Monnier wrote:
>> Using C-M-x, or just by putting it in my .emacs.
> 
> I guess we could tweak C-M-x to try and make it work as well, but as for
> "just putting it in my .emacs" it should already work (and does work for
> me).
> 
> The code to handle it when loading a file is in
> readevalloop_eager_expand_eval (in src/lread.c), and the code to handle
> it for the byte-compiler is in byte-compile-recurse-toplevel (in
> bytecomp.el).
> 
> Hmm... looking further I see that it "should" already work.
> There's just a macroexpand-all that gets in the way.
> So the patch below (which I pushed to master) makes it work (at least
> for the non-edebug case).

Thanks, that works!  Unfortunately, it looks like I oversimplified the problem, 
and the the more complete example below is still misbehaved.  Sorry for the 
oversimplification.

Here's a repro closer to the problem we ran into in Flycheck:

* In a new file test-macro.el, write this:
  
  (defmacro mmm (f)
    `(function ,f))
  (provide 'test-macro)

* In a new file test.el, write this

  (with-eval-after-load 'test-macro
    (let ((out (mmm (lambda ()))))
      (message "with-eval-after-load: %S" out)))

  (load (expand-file-name "test-macro.el"))

* In test.el, run M-x eval-buffer; I get the following output:

  Loading /tmp/test-macro.el (source)...
  with-eval-after-load: #'(lambda nil)
  Loading /tmp/test-macro.el (source)...done

* In test.el, run M-x eval-buffer again; I get the output shown below.  The 
printed value changes from #'(lambda nil) to (lambda nil), and the 
with-eval-after-load message is printed twice during loading, for some reason:

  with-eval-after-load: (lambda nil)
  Loading /tmp/test-macro.el (source)...
  with-eval-after-load: #'(lambda nil)
  with-eval-after-load: (lambda nil)
  Loading /tmp/test-macro.el (source)...done

I get these results on the latest master.

Thanks for your help!
Clément.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]