[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#27016: possible bug in `defsetf'
From: |
npostavs |
Subject: |
bug#27016: possible bug in `defsetf' |
Date: |
Mon, 22 May 2017 19:15:57 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) |
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
- bug#27016: possible bug in `defsetf', Rafael D Sorkin, 2017/05/22
- bug#27016: possible bug in `defsetf', npostavs, 2017/05/22
- bug#27016: possible bug in `defsetf', Rafael D Sorkin, 2017/05/22
- bug#27016: possible bug in `defsetf', npostavs, 2017/05/22
- bug#27016: possible bug in `defsetf', Michael Heerdegen, 2017/05/22
- bug#27016: possible bug in `defsetf', npostavs, 2017/05/22
- bug#27016: possible bug in `defsetf', Michael Heerdegen, 2017/05/22
- bug#27016: possible bug in `defsetf', npostavs, 2017/05/22
- bug#27016: possible bug in `defsetf', Michael Heerdegen, 2017/05/22
bug#27016: possible bug in `defsetf', Rafael D Sorkin, 2017/05/22
- bug#27016: possible bug in `defsetf',
npostavs <=
bug#27016: possible bug in `defsetf', Rafael D Sorkin, 2017/05/24
bug#27016: possible bug in `defsetf', Rafael D Sorkin, 2017/05/25
bug#27016: possible bug in `defsetf', Rafael D Sorkin, 2017/05/25