emacs-devel
[Top][All Lists]
Advanced

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

Re: Customizing the VC backend order


From: David Kastrup
Subject: Re: Customizing the VC backend order
Date: Sat, 11 Aug 2007 11:22:22 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

Andreas Schwab <address@hidden> writes:

> dhruva <address@hidden> writes:
>
>> Not so important/relavent: I went through the 'C' implementation of
>> 'nconc'. I find it concatenates 2'nd to the 1'st, 3'rd to the 2'nd...
>> N'th to the (N-1)'st and returns the 1'st list. I wonder how it can
>> get into an infinite loop.
>
> nconc can generate circular lists.

Which is what happens on the second iteration.  And on the third
iteration, nconc gets stuck trying to find the end of the circular
list in order to append to it.

nconc is _destructive_ on all but its last element.  So you need to
provide it with a list that you know you won't need later anymore.

You can write
(nconc (list 'Hg) something)
without any problem, since you generate a new list on any call.  And
you can even write verbatim
(nconc '(Hg) something)
as the reader generates a new list to nconc whenever it reads the
expression.  But as soon as you stick this into a loop or function or
anything else, the reader creates _one_ static list when he reads the
above expression.  And this list is _reused_ after it gets manipulated
with nconc.

Lisp is a dynamic language: all its programs are lists themselves, and
can be manipulated like lists.  And that is what you do here.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum




reply via email to

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