help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Basic Emacs Lisp question


From: David Kastrup
Subject: Re: Basic Emacs Lisp question
Date: Wed, 30 Apr 2008 17:26:25 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Giorgos Keramidas <keramida@ceid.upatras.gr> writes:

> On Tue, 29 Apr 2008 17:49:19 +0200, Matthias Pfeifer <pfemat@web.de> wrote:
>> Hello,
>>
>> What is the difference between
>>
>> (list 0 nil -1)
>>
>> and
>>
>> '(0 nil -1)
>
> In Common Lisp (list 0 nil -1) is required to 'cons' a new list every
> time it is called.  Quoting the list as in '(0 nil -1) is not required
> to build a new list.  In fact, in compiled code it may reuse the same
> static object over and over again.

Wrong word choice.  Not "may", but "must".  ' produces a list in the
Lisp reader.  Nothing may afterwards create gratuitious unannounced
copies.  So whether your code is compiled or interpreted: if it is not
reread, no new object is created.

I can write (interpreted)

(progn (setq x '(5)) (dotimes (i 5) (push i x)) x)
and get
(4 3 2 1 0 5)

and that is the only permitted behavior.

In contrast, list must always create a fresh object.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum


reply via email to

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