From: npostavs@users.sourceforge.net
To: Rafael D Sorkin <rsorkin@perimeterinstitute.ca>
Cc: 27016@debbugs.gnu.org
Subject: bug#27016: possible bug in `defsetf'
Date: Mon, 22 May 2017 19:15:57 -0400 [thread overview]
Message-ID: <87a864fpoy.fsf@users.sourceforge.net> (raw)
In-Reply-To: <E1dCvPw-0002Nz-BU@mars.pi.local> (Rafael D. Sorkin's message of "Mon, 22 May 2017 18:03:08 -0400")
Rafael D Sorkin <rsorkin@perimeterinstitute.ca> writes:
> Thanks, I was wondering about that myself. Is there a standard
> for elisp (or common lisp) that would determine whether eager
> macro expansion is an error in this case?
CLTL says this[1]:
The evaluator is typically implemented as an interpreter that traverses
the given form recursively, performing each step of the computation as
it goes. An interpretive implementation is not required, however. A
permissible alternative approach is for the evaluator first to
completely compile the form into machine-executable code and then invoke
the resulting code. This technique virtually eliminates
incompatibilities between interpreted and compiled code but also renders
the evalhook mechanism relatively useless. Various mixed strategies are
also possible. All of these approaches should produce the same results
when executing a correct program but may produce different results for
incorrect programs. For example, the approaches may differ as to when
macro calls are expanded; macro definitions should not depend on the
time at which they are expanded. Implementors should document the
evaluation strategy for each implementation.
and this[2] specifically about defsetf:
X3J13 voted in March 1989 (DEFINING-MACROS-NON-TOP-LEVEL) to clarify
that, while defining forms normally appear at top level, it is
meaningful to place them in non-top-level contexts; the complex form of
defsetf must define the expander function within the enclosing lexical
environment, not within the global environment.
I'm not sure whether (unless ...) counts as an "enclosing lexical
environment" though.
> I would expect that a `defun' or `defsetf' etc which is within a
> conditional would not be executed until it was known whether the
> condition was satisfied. The opposite behavior seems
> counter-intuitive to me.
`defun' takes effect at runtime (or rather it expands to `defalias'
which operates at runtime), whereas `defsetf' has to affect subsequent
compilation, so waiting until runtime to decide whether the condition is
true could not really work.
> But if you decide that this behavior is not a bug, then please
> let me know, so that I can adapt to it in the future.
I *think* it's not a bug, or at least not one worth fixing. If you wrap
your (unless ...) form in (eval-when-compile ...) then you get your
expected behaviour.
[1]: https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node179.html
[2]: https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node80.html
next prev parent reply other threads:[~2017-05-22 23:15 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-22 6:39 bug#27016: possible bug in `defsetf' Rafael D Sorkin
2017-05-22 12:11 ` npostavs
2017-05-22 20:25 ` Rafael D Sorkin
2017-05-22 21:18 ` npostavs
2017-05-22 23:10 ` Michael Heerdegen
2017-05-22 23:23 ` npostavs
2017-05-23 0:45 ` Michael Heerdegen
2017-05-23 0:51 ` npostavs
2017-05-23 1:18 ` Michael Heerdegen
2017-05-22 22:03 ` Rafael D Sorkin
2017-05-22 23:15 ` npostavs [this message]
2017-05-24 4:52 ` Rafael D Sorkin
2017-05-24 22:51 ` Michael Heerdegen
2017-05-25 1:50 ` npostavs
2017-05-25 4:59 ` Rafael D Sorkin
2017-05-25 5:01 ` Rafael D Sorkin
2017-05-25 10:38 ` npostavs
2017-05-25 20:26 ` Michael Heerdegen
2017-05-25 20:42 ` Noam Postavsky
2017-05-25 21:31 ` Michael Heerdegen
2017-05-25 23:03 ` npostavs
2017-05-25 23:40 ` Michael Heerdegen
2017-05-26 3:50 ` Stefan Monnier
2017-05-26 22:51 ` npostavs
2017-05-28 20:45 ` Stefan Monnier
2017-07-02 20:47 ` npostavs
2017-07-03 11:25 ` Michael Heerdegen
2017-07-09 20:13 ` npostavs
2017-07-10 0:26 ` Michael Heerdegen
2017-07-11 1:45 ` npostavs
2017-07-11 16:21 ` Stefan Monnier
2017-07-12 0:55 ` npostavs
2017-07-12 2:01 ` Stefan Monnier
2017-07-13 4:46 ` npostavs
2017-07-13 14:25 ` Stefan Monnier
2017-07-14 0:39 ` npostavs
2017-07-14 3:48 ` Stefan Monnier
2017-07-14 4:32 ` Stefan Monnier
2017-07-15 14:51 ` npostavs
2017-07-16 1:03 ` Stefan Monnier
2017-08-08 1:18 ` npostavs
2017-05-26 5:05 ` Rafael D Sorkin
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=87a864fpoy.fsf@users.sourceforge.net \
--to=npostavs@users.sourceforge.net \
--cc=27016@debbugs.gnu.org \
--cc=rsorkin@perimeterinstitute.ca \
/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).