[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using Emacs Lisp for script writing
From: |
Cecil Westerhof |
Subject: |
Re: Using Emacs Lisp for script writing |
Date: |
Tue, 22 Dec 2009 17:54:16 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux) |
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
- Re: Using Emacs Lisp for script writing, (continued)
- Re: Using Emacs Lisp for script writing, Andreas Politz, 2009/12/18
- Message not available
- Re: Using Emacs Lisp for script writing, Cecil Westerhof, 2009/12/21
- Re: Using Emacs Lisp for script writing, Sam Steingold, 2009/12/21
- Re: Using Emacs Lisp for script writing, Sam Steingold, 2009/12/21
- Re: Using Emacs Lisp for script writing, Tim X, 2009/12/21
- Re: Using Emacs Lisp for script writing, Cecil Westerhof, 2009/12/21
- Re: Using Emacs Lisp for script writing, Tim X, 2009/12/22
- Re: Using Emacs Lisp for script writing, Cecil Westerhof, 2009/12/22
- Re: Using Emacs Lisp for script writing, Pascal J. Bourguignon, 2009/12/22
- Re: Using Emacs Lisp for script writing,
Cecil Westerhof <=
- Re: Using Emacs Lisp for script writing, Tim X, 2009/12/22
- Re: Using Emacs Lisp for script writing, Cecil Westerhof, 2009/12/23
- Message not available
- Re: Using Emacs Lisp for script writing, Cecil Westerhof, 2009/12/21
- Re: Using Emacs Lisp for script writing, Tim X, 2009/12/22
- Re: Using Emacs Lisp for script writing, Pascal J. Bourguignon, 2009/12/22
- Re: Using Emacs Lisp for script writing, Cecil Westerhof, 2009/12/22
- Re: Using Emacs Lisp for script writing, Pascal J. Bourguignon, 2009/12/22
- Re: Using Emacs Lisp for script writing, Cecil Westerhof, 2009/12/22
- Re: Using Emacs Lisp for script writing, Tim X, 2009/12/22
- Re: Using Emacs Lisp for script writing, Cecil Westerhof, 2009/12/23