[Top][All Lists]

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

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

From: Stefan Monnier
Subject: Re: A combination of defmacro, functionp, and quoted lambdas yields different results on consecutive evaluations
Date: Mon, 26 Feb 2018 12:13:23 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> My user's problem is the following: Flycheck defines a macro that lets
> you define a new checker.  One of our users wrote something like this:
> (with-eval-after-load 'flycheck
>   (flycheck-define-checker
>     …))
> This doesn't work.  I claim that it should, or that it should be
> documented to not work.  Do you disagree?

I think it is or should be documented, indeed, but not in
`with-eval-after-load` since this applies to everything else as well.

If you need to use a macro that's in file `foo`, then AFAIK you have
2 options:

- (require 'foo), either directly or transitively.
- hide your macro call behind a quote so it can't be compiled before
  `foo` is loaded (regardless of whether you do compile or not
  irrelevant: the right way to think about it is "what happens when it
  gets compiled").

> Because of the documentation says that this macro arranges for evaluation to
> be delayed.

But macro expansion can take place long before evaluation.
E.g. `defun` also delays evaluation of its body.  But

    (defun foo ()
      ... (mmm blabla) ...)

    (defmacro mmm (...) ...)

will suffer from the same problem (tho at least in this particular
case, the byte-compiler will notice and emit a warning, IIRC).


reply via email to

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