[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Basic questions about elisp
From: |
Francis Moreau |
Subject: |
Re: Basic questions about elisp |
Date: |
Fri, 06 Nov 2009 21:53:14 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) |
David Kastrup <dak@gnu.org> writes:
> Francis Moreau <francis.moro@gmail.com> writes:
[...]
>>
>> Basic principle of _elisp_ programming, I asssume...
>
> Of Lisp programming.
>
>>> Only ever use destructive list operators like nconc on lists that
>>> have been consed together _entirely_ under your control.
>>>
>>> In this particular case, the cons '(2) has been consed together under
>>> control of the Lisp reader. The second time this code gets executed,
>>> the cons is destroyed.
>>
>> eh ?
>
> Did you try my example?
nope I was a bit confused by what you wrote and your example was using
'dotimes'.
>
>
>> When I wrote '(2), I suppose the elisp interpreter to create a new
>> list.
>
> It does so, but at read time. Not execution time.
>
Ah ok I see what you mean now.
That's a pretty important point, is this part covered by the elisp info ?
Actually the same stands for the implementation of the list, where
nconc, length... are O(n). I wouldn't have thought that lists are really
implemented by the car & cdr thing only.
>
> And
>
> (let ((lst (list 1 2 3)))
> (dolist (elt lst)
> (when (< elt 3)
> (nconc lst '(4))))
> lst)
>
> just crashes.
OK.
--
Francis
Re: Basic questions about elisp, tomas, 2009/11/05
Message not available
Re: Basic questions about elisp, Pascal J. Bourguignon, 2009/11/05
- Re: Basic questions about elisp, David Kastrup, 2009/11/05
- Re: Basic questions about elisp, Francis Moreau, 2009/11/06
- Re: Basic questions about elisp, David Kastrup, 2009/11/06
- Re: Basic questions about elisp,
Francis Moreau <=
- Re: Basic questions about elisp, Pascal J. Bourguignon, 2009/11/06
- Re: Basic questions about elisp, Francis Moreau, 2009/11/07
- Re: Basic questions about elisp, Pascal J. Bourguignon, 2009/11/07
- Re: Basic questions about elisp, tomas, 2009/11/08
- Message not available
- Re: Basic questions about elisp, Francis Moreau, 2009/11/09
Re: Basic questions about elisp, Francis Moreau, 2009/11/08
Re: Basic questions about elisp, tomas, 2009/11/08
Re: Basic questions about elisp, Pascal J. Bourguignon, 2009/11/08
Re: Basic questions about elisp, Francis Moreau, 2009/11/09
Re: Basic questions about elisp, Joost Kremers, 2009/11/10