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: Mon, 09 Nov 2009 21:51:18 +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> <878wejcpys.fsf@galatea.local> <8229723a-5415-4a8e-b306-8e694f9cccb7@a32g2000yqm.googlegroups.com> 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 1257802957 6165 80.91.229.12 (9 Nov 2009 21:42:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 9 Nov 2009 21:42:37 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 09 22:42:31 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 1N7c0L-00084q-BE for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Nov 2009 22:42:29 +0100 Original-Received: from localhost ([127.0.0.1]:36101 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N7c0K-0000Qz-Pn for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Nov 2009 16:42:28 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.straub-nv.de!proxad.net!feeder1-2.proxad.net!cleanfeed4-a.proxad.net!nnrp4-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:fzisU5WB2dLzY9Xg8mbSZBF1Zqc= Original-Lines: 41 Original-NNTP-Posting-Date: 09 Nov 2009 21:51:25 MET Original-NNTP-Posting-Host: 82.235.205.153 Original-X-Trace: 1257799885 news-4.free.fr 9923 82.235.205.153:33553 Original-X-Complaints-To: abuse@proxad.net Original-Xref: news.stanford.edu gnu.emacs.help:174563 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:69637 Archived-At: tomas@tuxteam.de writes: > On Sat, Nov 07, 2009 at 06:49:52AM -0800, Francis Moreau wrote: >> On 6 nov, 22:18, p...@informatimago.com (Pascal J. Bourguignon) wrote: >> > Francis Moreau writes: > > [...] > >> > > 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. >> > >> > Why not?  If people have been repeating for 50 years that lisp lists >> > are implemented with cons, car and cdr... >> >> Because I can understand there were some memory constraints 50 years >> ago that force lisp lists to be as small as possible. But I would have >> thought lisp lists (or (e)lisp) to evolve as computer memories did. > > There's no "one data structure fits all" philosophy here. Use list for > "list things" and arrays for "array things". Nowadays all Lisps have > some form or other of array. > > And still, lists are among the strongest points of Lisp. They are > simple and flexible, they are the representation of Lisp programs. They > are the reason why Lisp programmers are writing programs that write > programs ever since ~50 years ago. > > If a list doesn't fit your bill, by all means: use defstruct, use > arrays, use hashes. But (as Pascal pointed out), sometimes lists fit a > bill quite unexpectedly, if you are willing to think flexibly (e.g. push > new elements at the head instead of append, etc). yeah, optimized push/pop operations of lists is a bit unusual for me, it's actually like using stack instead of lists. Specially since the first code I tried to write with elisp was a sort algo where order matters and first parsed elements need to be the first ones in the list. Thanks -- Francis