[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is this a bug of Emacs-Lisp?
From: |
Giorgos Keramidas |
Subject: |
Re: Is this a bug of Emacs-Lisp? |
Date: |
Fri, 17 Feb 2006 18:21:37 +0200 |
On 2006-02-17 13:47, Zhang Wei <address@hidden> wrote:
> (defun dummy () '(1 . 2))
>
> (dummy)
> => (1 . 2)
>
> (setcdr (dummy) 3)
>
> (dummy)
> => (1 . 3)
>
> Modify the return value of dummy changed it's defination. Is this
> a bug of Elisp? If it's not. How does this happen?
You are modifying a `literal' cons cell. It's not mandatory for the
LISP reader to create a new cons cell every time the (dummy) function
runs.
If you really want to create a new cons cell every time (dummy) runs,
you'll have to explicitly do that in the function:
(defun dummy ()
(copy-tree '(1 . 2)))
=> dummy
(setcdr (dummy) 3)
=> 3
(dummy)
=> '(1 . 2)
- Is this a bug of Emacs-Lisp?, Zhang Wei, 2006/02/17
- Re: Is this a bug of Emacs-Lisp?, David Kastrup, 2006/02/17
- Re: Is this a bug of Emacs-Lisp?, Kevin Rodgers, 2006/02/17
- Re: Is this a bug of Emacs-Lisp?,
Giorgos Keramidas <=
- Re: Is this a bug of Emacs-Lisp?, Andreas Schwab, 2006/02/17
- Re: Is this a bug of Emacs-Lisp?, Luc Teirlinck, 2006/02/17
- Re: Is this a bug of Emacs-Lisp?, Luc Teirlinck, 2006/02/17
- Re: Is this a bug of Emacs-Lisp?, Alan Mackenzie, 2006/02/17
- Re: Is this a bug of Emacs-Lisp?, Sascha Wilde, 2006/02/17
- Re: Is this a bug of Emacs-Lisp?, Richard M. Stallman, 2006/02/18