Subject: bug#14422: 24.3; Eager Macro Expansion

From: Achim Gratz <[email-masked]>
Date: Thu, 30 May 2013 21:38:21 +0200

Stefan Monnier writes:
> I see the test fails, but that's just because the test is wrong.
[…]
> You'll see that your code behaves differently when byte-compiled.

Yes, we've already established that the original code itself had a bug.
The correct code would look like this

(defvar eme-ll nil)

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

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

(provide 'eme)

The remaining point is that the ERT test still fails in exactly the same
way when it is _not_ byte-compiled and batch-tested (like the original
case in Org), but it produces the correct result when testing in
interactive mode or in the debugger.  I guess I'm asking for a warning
for recursive macro expansions that manipulate the same variable both at
expansion and at runtime in separate macros.  Alternatively if the buggy
code would always fail in the same way that would at least ensure it can
be found more easily.

Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Wavetables for the Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#BlofeldUserWavetables