From: "Clément Pit-Claudel" <cpitclaudel@gmail.com>
To: Emacs developers <emacs-devel@gnu.org>
Subject: A combination of defmacro, functionp, and quoted lambdas yields different results on consecutive evaluations
Date: Sat, 17 Feb 2018 11:04:07 -0500 [thread overview]
Message-ID: <08190786-14de-a899-f591-a7043c87bebb@gmail.com> (raw)
Hey Emacs-devel,
We recently ran into a problem in Flycheck that confused us. Evaluating the following twice yields different results on the first evaluation (nil) and on the subsequent ones (t):
;; nil on the first run; t on subsequent ones
(progn
(defmacro m (f)
`(function ,f))
(functionp (m (lambda ()))))
Here it is with more info added:
;; "NOK #'(lambda nil)" on the first run; "OK (lambda nil)" on subsequent runs.
(progn
(defmacro m8 (f)
`(function ,f))
(let ((out (m8 (lambda ()))))
(message "%s %S"
(if (functionp out) "OK" "NOK")
out)))
This seems to stem from the way macro-evaluation works: running macroexpand-last-sexp before the first evaluation yields this:
(progn
(defalias 'm (cons 'macro #'(lambda (f) (list 'function f))))
(functionp (m #'(lambda nil))))
… but on subsequent evaluations it yields that:
(progn
(defalias 'm (cons 'macro #'(lambda (f) (list 'function f))))
(functionp #'(lambda nil)))
Is this expected? Did we miss something in the manual about this?
Background info: https://github.com/flycheck/flycheck/issues/1398
Thanks!
Clément.
next reply other threads:[~2018-02-17 16:04 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-17 16:04 Clément Pit-Claudel [this message]
2018-02-17 21:58 ` A combination of defmacro, functionp, and quoted lambdas yields different results on consecutive evaluations Stefan Monnier
2018-02-18 15:17 ` Clément Pit-Claudel
2018-02-18 18:02 ` Stefan Monnier
2018-02-25 18:09 ` Clément Pit-Claudel
2018-02-26 3:18 ` Stefan Monnier
2018-02-26 5:40 ` Clément Pit-Claudel
2018-02-26 13:11 ` Stefan Monnier
2018-02-26 15:20 ` Clément Pit-Claudel
2018-02-26 16:31 ` Stefan Monnier
2018-02-26 16:38 ` Stefan Monnier
2018-02-26 17:08 ` Clément Pit-Claudel
2018-02-26 17:31 ` Stefan Monnier
2018-02-28 14:32 ` Clément Pit-Claudel
2018-02-28 16:02 ` Stefan Monnier
2018-02-26 17:01 ` Clément Pit-Claudel
2018-02-26 17:13 ` Stefan Monnier
2018-02-26 17:32 ` Clément Pit-Claudel
2018-02-26 17:40 ` Clément Pit-Claudel
2018-03-01 0:50 ` Radon Rosborough
2018-02-27 21:35 ` Stefan Monnier
2018-02-28 12:44 ` Michael Heerdegen
2018-02-28 13:31 ` Stefan Monnier
2018-02-28 14:26 ` Clément Pit-Claudel
2018-02-28 23:12 ` Stefan Monnier
2018-02-26 13:13 ` Stefan Monnier
2018-02-26 15:20 ` Clément Pit-Claudel
2018-02-26 16:33 ` Stefan Monnier
2018-02-26 16:37 ` Michael Heerdegen
2018-02-26 17:15 ` Clément Pit-Claudel
2018-02-26 17:38 ` Stefan Monnier
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=08190786-14de-a899-f591-a7043c87bebb@gmail.com \
--to=cpitclaudel@gmail.com \
--cc=emacs-devel@gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.