From: Cecil Westerhof <Cecil@decebal.nl>
To: help-gnu-emacs@gnu.org
Subject: Re: Using Emacs Lisp for script writing
Date: Tue, 22 Dec 2009 17:54:16 +0100 [thread overview]
Message-ID: <87ws0f2blz.fsf@Traian.DecebalComp> (raw)
In-Reply-To: 87637zrpev.fsf@hubble.informatimago.com
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
next prev parent reply other threads:[~2009-12-22 16:54 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-16 15:32 Using Emacs Lisp for script writing Cecil Westerhof
2009-12-16 16:24 ` Sam Steingold
2009-12-16 17:18 ` Teemu Likonen
2009-12-16 23:37 ` Cecil Westerhof
2009-12-17 19:08 ` Sam Steingold
2009-12-16 23:04 ` Pascal J. Bourguignon
2009-12-18 21:39 ` Andreas Politz
2009-12-19 10:02 ` David Engster
[not found] ` <mailman.13065.1260980854.2239.help-gnu-emacs@gnu.org>
2009-12-16 23:31 ` Cecil Westerhof
2009-12-17 11:29 ` Cecil Westerhof
2009-12-21 18:35 ` Frank Fredstone
2009-12-21 19:20 ` Cecil Westerhof
2009-12-21 20:57 ` Sam Steingold
2009-12-21 21:13 ` Sam Steingold
2009-12-21 23:06 ` Tim X
2009-12-22 0:46 ` Cecil Westerhof
2009-12-22 11:26 ` Tim X
2009-12-22 13:51 ` Cecil Westerhof
2009-12-22 15:36 ` Pascal J. Bourguignon
2009-12-22 16:54 ` Cecil Westerhof [this message]
2009-12-23 2:50 ` Tim X
2009-12-23 7:38 ` Cecil Westerhof
[not found] ` <mailman.18.1261429198.1956.help-gnu-emacs@gnu.org>
2009-12-22 0:06 ` Cecil Westerhof
2009-12-22 12:51 ` Tim X
2009-12-22 15:42 ` Pascal J. Bourguignon
2009-12-22 17:04 ` Cecil Westerhof
2009-12-22 19:02 ` Pascal J. Bourguignon
2009-12-22 20:49 ` Cecil Westerhof
2009-12-23 3:19 ` Tim X
2009-12-23 6:27 ` Cecil Westerhof
[not found] ` <mailman.21.1261430019.1956.help-gnu-emacs@gnu.org>
2009-12-22 0:28 ` Cecil Westerhof
2014-05-10 5:54 ` mug896
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ws0f2blz.fsf@Traian.DecebalComp \
--to=cecil@decebal.nl \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).