From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Cecil Westerhof Newsgroups: gmane.emacs.help Subject: Re: Using Emacs Lisp for script writing Date: Tue, 22 Dec 2009 17:54:16 +0100 Organization: Decebal Computing Message-ID: <87ws0f2blz.fsf@Traian.DecebalComp> References: <87hbrrrl3c.fsf@Traian.DecebalComp> <87vdg09ls9.fsf@Traian.DecebalComp> <878wcw53mj.fsf@lion.rapttech.com.au> <87pr677s4z.fsf@Traian.DecebalComp> <874onj5jxu.fsf@lion.rapttech.com.au> <87ljgv3ymp.fsf@Traian.DecebalComp> <87637zrpev.fsf@hubble.informatimago.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1261503658 16648 80.91.229.12 (22 Dec 2009 17:40:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 22 Dec 2009 17:40:58 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Dec 22 18:40:51 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 1NN8j2-0001IF-8D for geh-help-gnu-emacs@m.gmane.org; Tue, 22 Dec 2009 18:40:48 +0100 Original-Received: from localhost ([127.0.0.1]:51476 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NN8j2-0006kW-Dz for geh-help-gnu-emacs@m.gmane.org; Tue, 22 Dec 2009 12:40:48 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Original-Newsgroups: gnu.emacs.help X-Homepage: http://www.decebal.nl/ User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux) Cancel-Lock: sha1:Lp29Zy1BuMzA49PMTDUBKX2v8Bw= Original-Lines: 73 Original-NNTP-Posting-Host: 84.53.123.169 Original-X-Trace: 1261500856 news.xs4all.nl 22944 decebal/[::ffff:84.53.123.169]:16387 Original-X-Complaints-To: abuse@xs4all.nl Original-Xref: news.stanford.edu gnu.emacs.help:175730 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:70806 Archived-At: pjb@informatimago.com (Pascal J. Bourguignon) writes: >> I'll try to keep that in mind. But compiling the regular expression made >> a big difference. Also, I remember someone telling me that lists are not >> very efficient. > > See? This is what we meant when we told you that you need to know > more before trying to optimize things out! > > Adding an element to a list or removing one is O(1) (when it's the > first element of the list). Doing the same with a vector is O(n). > With a tree it'll be O(log(n)), and with a hash-table, it will be O(1) > amortized, that is, the constant factors will kill you. > > Now of course if your algorithm is not adding or removing the first > element of the data structure, the time complexities and constant > factors will be different. Thanks. I'll keep those things in mind. >> What should I use instead? Or will I found that out in >> Practical Common Lisp? > > Practical Common Lisp is only the first step. There is a lot of > literature to read and programs to write to learn what has to be > learnt. > > Browse the cliki: > > http://cliki.net/Education > http://cliki.net/Online%20Tutorial > http://cliki.net/Lisp%20books I'll do that. >> Another question. The BBDB and also the example in Practical Common Lisp >> use lists for the database. Is this not inefficient? > > No, not in those conditions of application. > > >> Would a real database not be better. Not that I want to burn me at >> the moment on databases. ;-) > > A real database would be overkill to store five records. Just > "opening" the database would takes hundreds times more of cycles than > pushing onto a list, and don't you know the speed differential between > memory write and disk writes? > > > Remember this is a "simple database", a small example given to give a > taste of lisp before even introducing the Syntax of lisp! Yes, but the BBDB could become quit big I would think. Maybe a tree would be better as a list. But I have enough to worry about. So I'll put it on the back burner. > But the most important thing you should have learnt from this chapter, > is not that it used lists to store the records, but that the storing > of the records was abstracted away with a add-record function. That > means that all the programs presented in this chapter will work the > same once you hook a disk based database under add-record instead of > the simple list (See SICP). Abstraction is always good to do. SICP was already on my list to read. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof