From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: tomas@tuxteam.de Newsgroups: gmane.emacs.help Subject: Re: Basic questions about elisp Date: Sun, 8 Nov 2009 10:46:18 +0100 Message-ID: <20091108094618.GA17095@tomas> 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=utf-8; x-action=pgp-signed Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1257674187 32485 80.91.229.12 (8 Nov 2009 09:56:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 8 Nov 2009 09:56:27 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Francis Moreau Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Nov 08 10:56:20 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 1N74VK-0007YU-5b for geh-help-gnu-emacs@m.gmane.org; Sun, 08 Nov 2009 10:56:14 +0100 Original-Received: from localhost ([127.0.0.1]:40353 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N74VJ-0006Pg-I7 for geh-help-gnu-emacs@m.gmane.org; Sun, 08 Nov 2009 04:56:13 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N74Tu-0005sm-HX for help-gnu-emacs@gnu.org; Sun, 08 Nov 2009 04:54:46 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N74To-0005oq-U4 for help-gnu-emacs@gnu.org; Sun, 08 Nov 2009 04:54:45 -0500 Original-Received: from [199.232.76.173] (port=54716 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N74To-0005of-Nm for help-gnu-emacs@gnu.org; Sun, 08 Nov 2009 04:54:40 -0500 Original-Received: from alextrapp1.equinoxe.de ([217.22.192.104]:47085 helo=www.elogos.de) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N74To-00016J-7I for help-gnu-emacs@gnu.org; Sun, 08 Nov 2009 04:54:40 -0500 Original-Received: by www.elogos.de (Postfix, from userid 1000) id 1A62A90048; Sun, 8 Nov 2009 10:46:18 +0100 (CET) Content-Disposition: inline In-Reply-To: <8229723a-5415-4a8e-b306-8e694f9cccb7@a32g2000yqm.googlegroups.com> User-Agent: Mutt/1.5.15+20070412 (2007-04-11) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) 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:69597 Archived-At: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 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 r= eally > > > implemented by the car & cdr thing only. > > > > Why not? =C2=A0If people have been repeating for 50 years that lisp l= ists > > are implemented with cons, car and cdr... >=20 > 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). Ah, btw. Some Lisp implementations optimize runs of lists as arrays behind the scenes (search for "cdr compression"). But you still get this nice, simple and expressive programming interface. Regards - -- tom=C3=A1s -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFK9pNqBcgs9XrR2kYRArYpAJ9/CnR5m6JBknoM3FcDVMrlqyDBygCfeKVh 2QyoTVHjkwWxtb/Uu8Abj1o=3D =3DZmom -----END PGP SIGNATURE-----