* bug#9482: Documentation bug: Emacs Lisp Manual should say quoting does not cons explicitly in quoting section. related to bug#9469
@ 2011-09-12 15:01 Le Wang
2011-09-13 13:25 ` bug#9482: specific manual text suggestion Le Wang
0 siblings, 1 reply; 3+ messages in thread
From: Le Wang @ 2011-09-12 15:01 UTC (permalink / raw)
To: 9482
Relevant page here:
http://www.gnu.org/s/emacs/manual/html_node/elisp/Quoting.html
I was confused and always assumed that
'(a . b)
is simply short hand for
(cons 'a 'b)
Reading stackexchange, it seems at least some other people are under
this impression as well. This works a majority of the time, but when
it fails it's really surprising.
In fact, the manual already has an example of this pit-fall in the
nconc section: http://www.gnu.org/software/emacs/elisp/html_node/Rearrangement.html
I think the quoting section should give an explicit warning with a
reference to the nconc example.
--
Le
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#9482: specific manual text suggestion
2011-09-12 15:01 bug#9482: Documentation bug: Emacs Lisp Manual should say quoting does not cons explicitly in quoting section. related to bug#9469 Le Wang
@ 2011-09-13 13:25 ` Le Wang
2011-09-16 14:14 ` Stefan Monnier
0 siblings, 1 reply; 3+ messages in thread
From: Le Wang @ 2011-09-13 13:25 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 9482
Hi Stefan,
As I mentioned in this bug. The manual already has an example of this
trap in the nconc section. Maybe just a pointer to it.
So my suggestion for specific text would be:
"WARNING: '(a . b) is not short-hand for (cons 'a 'b). The former
does not cons. Quoting should be reserved for constants that will
*NEVER* change. See <link>nconc</link> for example of unexpected
results when a quoted object is modified."
My terminology may be not quite right, but if I read something like
this, the difference would be much clearer.
--
Le
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#9482: specific manual text suggestion
2011-09-13 13:25 ` bug#9482: specific manual text suggestion Le Wang
@ 2011-09-16 14:14 ` Stefan Monnier
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2011-09-16 14:14 UTC (permalink / raw)
To: Le Wang; +Cc: 9482-done
> My terminology may be not quite right, but if I read something like
> this, the difference would be much clearer.
Thanks for your sample text. I tweaked it a bit to make it hopefully
even more explicit, see patch below.
Stefan
--- src/eval.c 2011-09-09 01:06:52 +0000
+++ src/eval.c 2011-09-16 14:09:39 +0000
@@ -475,6 +475,14 @@
DEFUN ("quote", Fquote, Squote, 1, UNEVALLED, 0,
doc: /* Return the argument, without evaluating it. `(quote x)' yields `x'.
+Warning: `quote' does not construct its return value, but just returns
+the value that was pre-constructed by the Lisp reader (see info node
+`(elisp)Printed Representation').
+This means that '(a . b) is not identical to (cons 'a 'b): the former
+does not cons. Quoting should be reserved for constants that will
+never be modified by side-effects, unless you like self-modifying
+code. See the common pitfall in info node `(elisp)Rearrangement' for
+an example of unexpected results when a quoted object is modified.
usage: (quote ARG) */)
(Lisp_Object args)
{
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-09-16 14:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-12 15:01 bug#9482: Documentation bug: Emacs Lisp Manual should say quoting does not cons explicitly in quoting section. related to bug#9469 Le Wang
2011-09-13 13:25 ` bug#9482: specific manual text suggestion Le Wang
2011-09-16 14:14 ` Stefan Monnier
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.