Saturday, May 16, 2009

Emacs Lisp newbie

I studied (Emacs) Lisp a little bit and I got some concept of it. 'symbol' is one of them that fascinated me. It's like a Python variable, you can get its value by evaluating it, but it can also be stored in another symbol as a value. Interesting, isn't it?

While studying Lisp, I found there were some which didn't sound natural to me. 1) Dynamic scope is confusing. 2) I don't like macro. Though I understand the necessity of it, it can let you write a counter intuitive code too easily just like C. 3) And there are too many special forms, which doesn't look elegant. Do we really need setq? Maybe Having set is enough, isn't it?. Lisp is so different between variants (*) so I don't know if they are specific to Emacs lisp or common to all lisps.

(*)
They are so different that some variants have lazy evaluation and others don't!


I don't like a symbol having two values, function and value. A function is not just a value in Emacs Lisp and Common Lisp. Language designers are quite careful so there must be a reason but I don't know why they have made such a decision. In Scheme a function is just a value, which is not at all different from other values such as integer or string. If this type of simplicity is what Scheme attaches importance to, I prefer Scheme to Emacs Lisp. Simplicity rocks!

Now I can read the source code of basic Emacs major modes. But I'm still not good at writing a code yet (Is there a function in ELisp which is equivalent to range() in Python? I still don't know) I remember those days when I was a Python newbie.

If you are a Lisp master and notice I wrote something wrong please leave a comment.

2 comments:

Anonymous said...

Your last question showed up in google when I was looking for the answer myself. I found it at

http://www.gnu.org/software/emacs/elisp/html_node/Building-Lists.html

the function you seek is number-sequence

Best,
Bart

hohehohe2 [at] gmail.com said...

Hey Anonymous,
It's very helpful, thanks!