unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* quote doesn't produce a fresh object
@ 2004-06-06 21:47 Don Bashford
  2004-06-08 17:12 ` Kevin Rodgers
  0 siblings, 1 reply; 2+ messages in thread
From: Don Bashford @ 2004-06-06 21:47 UTC (permalink / raw)
  Cc: Donald Bashford

(defun myfun (x)
  (let ((xs '(nil)))
    (print xs)
    (setcar xs "foo"))
  t)

On first invocation, (myfun 'arg) prints (nil) and returns t, as
expected.  But on second invocation, it prints ("foo").  It seems in the
second invocation, the let variable xs gets the old object from the
previous invocation.  If '(nil) is changed to (list nil) in myfun, the
problem does not occur, so the problem is with quote, not with let.

GNU Emacs 21.2.1 (i386-redhat-linux-gnu, X toolkit, Xaw3d scroll bars)
of 2002-04-08 on porky.devel.redhat.com

(Also occurs with 21.3 from redhat)

-Don

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: quote doesn't produce a fresh object
  2004-06-06 21:47 quote doesn't produce a fresh object Don Bashford
@ 2004-06-08 17:12 ` Kevin Rodgers
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Rodgers @ 2004-06-08 17:12 UTC (permalink / raw)


Don Bashford wrote:
 > (defun myfun (x)
 >   (let ((xs '(nil)))
 >     (print xs)
 >     (setcar xs "foo"))
 >   t)
 >
 > On first invocation, (myfun 'arg) prints (nil) and returns t, as
 > expected.  But on second invocation, it prints ("foo").  It seems in the
 > second invocation, the let variable xs gets the old object from the
 > previous invocation.  If '(nil) is changed to (list nil) in myfun, the
 > problem does not occur, so the problem is with quote, not with let.

That is not a bug. 'FORM is equivalent to (quote FORM) and is used to
denote a constant Lisp object, so the xs symbol should reference the
original object (which is cons'ed when the defun form is read, not when
it is evaluated).

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-06-08 17:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-06 21:47 quote doesn't produce a fresh object Don Bashford
2004-06-08 17:12 ` Kevin Rodgers

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).