From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Francis Moreau Newsgroups: gmane.emacs.help Subject: Re: Basic questions about elisp Date: Fri, 06 Nov 2009 21:53:14 +0100 Organization: Guest of ProXad - France Message-ID: References: <1e9f8449-09ec-4a84-a332-9f05fadb8aa3@z41g2000yqz.googlegroups.com> <87iqdpdog1.fsf@galatea.local> <871vkdm2p1.fsf@lola.goethe.zz> <4d5245de-4a71-4be7-a445-6d033be48490@g23g2000yqh.googlegroups.com> <87zl6ziooo.fsf@lola.goethe.zz> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1257543666 24691 80.91.229.12 (6 Nov 2009 21:41:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 6 Nov 2009 21:41:06 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Nov 06 22:40:59 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1N6WY7-0000af-C2 for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Nov 2009 22:40:51 +0100 Original-Received: from localhost ([127.0.0.1]:35339 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N6WY6-0001PC-VO for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Nov 2009 16:40:50 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!newsserver.news.garr.it!kanaga.switch.ch!switch.ch!news.in2p3.fr!in2p3.fr!proxad.net!feeder1-2.proxad.net!cleanfeed4-a.proxad.net!nnrp20-2.free.fr!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) Cancel-Lock: sha1:oE0oTMMecO6hYBKHYbaazxp8XGY= Original-Lines: 56 Original-NNTP-Posting-Date: 06 Nov 2009 21:53:16 MET Original-NNTP-Posting-Host: 82.235.205.153 Original-X-Trace: 1257540796 news-1.free.fr 10263 82.235.205.153:40812 Original-X-Complaints-To: abuse@proxad.net Original-Xref: news.stanford.edu gnu.emacs.help:174486 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:69560 Archived-At: David Kastrup writes: > Francis Moreau 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