[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is this a bug of Emacs-Lisp?

From: Luc Teirlinck
Subject: Re: Is this a bug of Emacs-Lisp?
Date: Fri, 17 Feb 2006 11:57:42 -0600 (CST)

Zhang Wei wrote:

   (defun dummy () '(1 . 2))

    => (1 . 2)

   (setcdr (dummy) 3)

    => (1 . 3)

   Modify the return value of dummy changed it's defination. Is this
   a bug of Elisp?

No.  You get the same result in Common Lisp if you replace, in the
above, setcdr with rplacd.

   If it's not. How does this happen?

If a function returns a quoted cons, then after you change the cdr of
the cons, it still returns that (now changed) cons.

Using (defun dummy (cons 1 2)) will prevent this.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]