Emacs Lisp is a Lisp-2

207 views
Skip to first unread message

alux

unread,
Jan 2, 2011, 10:52:56 AM1/2/11
to learn-elisp-for-emacs
Hello,

I assume that almost nobody will get interested into Elisp who did not
look into any lisp before. Nevertheless some of them may have started
with Scheme and be not aware of the Lisp-1 vs Lisp-2 distinction
http://en.wikipedia.org/wiki/Common_Lisp#The_function_namespace
and will thus be highly irritated by Elisp (that is an Lisp-2).

Kind regards, alux



defining a variable:
(setq a 7)

defining a function
(defun a (x) (+ a x))

calling the function:
(a 6)

this gives the value of the variable:
a

this gives the function as a value:
(function a)

btw. this functional value can be called like this
(funcall (function +) 3 6)

...

Gordon Guthrie

unread,
Jan 2, 2011, 6:28:34 PM1/2/11
to learn-elis...@googlegroups.com
Alux

> I assume that almost nobody will get interested into Elisp who did not
> look into any lisp before.

Erk! I have no Lisp at all.

> Nevertheless some of them may have started
> with Scheme and be not aware of the Lisp-1 vs Lisp-2 distinction
> http://en.wikipedia.org/wiki/Common_Lisp#The_function_namespace
> and will thus be highly irritated by Elisp (that is an Lisp-2).

I know nothing of the difference between Lisp-1 and List-2 :(

Looks like I have some reading to do.

Gordon

--
Gordon Guthrie
CEO hypernumbers

http://hypernumbers.com
t: hypernumbers
+44 7776 251669

alux

unread,
Jan 3, 2011, 2:38:07 AM1/3/11
to learn-elisp-for-emacs
;-)

Reading about Lisp is usually interesting, so go for it ;-)

The distinction is like this:

In Scheme (a Lisp-1) a variable, if defined, has one meaning: Its
value. This value might be a value as we usually talk about it, or a
function. So, if you call (a 5), it will look up the value for a, and
try to apply it to 5. (Clojure is a Lisp-1 too, just for the curious.)

In Elisp (a Lisp-2) a variable, if defined, can have two meanings: Its
value, and its function. The value might be a value as we usually talk
about it. (But it may be a function to, we have to talk about this).
The function can AFAIK only be a function (at least thats the only
sensible content). So, if you call (a 5), it will look up the FUNCTION
for a (not the value), and try to apply it to 5.
If a has both, say
(setq a 5)
(defun a (x) (+ 3 x))
then
(a a)
will do the following: The a in operator position will be understood
as function, the one in argument position as variable.
(Common Lisp is a Lisp-2)

(Be aware of potential spelling mistakes in the code, I'm writing in a
subway, and didnt test as usual.)

The functions function and funcall, as mentioned in the first post,
take the function value that has been asigned to a symbol and give it
as a (usual) value; and call a usual value, respectively.

The names Lisp-1/-2 refer to the fact that a Lisp-2 as described has
two namespaces, one for values, one for functions.

kind regards, alux

Gordon Guthrie

unread,
Jan 3, 2011, 5:25:11 AM1/3/11
to learn-elis...@googlegroups.com
A

Ahah! So it is the sort of stuff I write about in lesson 2-4:
http://learn-elisp-for-emacs.org/rsts/lesson-2-4.html

Do you think there should be a little section there about
Lisp-1/Lisp-2 and how they are different?

Maybe use the (a a) example you suggest?

Also in eLisp a symbol can have 4 properties :(
* print name
* variable name
* function
* property list

See http://www.gnu.org/software/emacs/emacs-lisp-intro/elisp/Symbol-Components.html#Symbol-Components

G

alux

unread,
Jan 3, 2011, 12:31:26 PM1/3/11
to learn-elisp-for-emacs
Well, take care where I try to push you ;-)

I'd suggest to write a Lisp book using Elisp to explain it. That of
course differs from your start intend.

So every now and then I'd suggest to have some side remarks, and talk
about the different ways Lisps do stuff.

I strongly advise to take something along the lines of my example, to
make the difference clear between function and value.

Then the book may or may not look beyond our own nose and tell about
different flavours of Lisp.

Btw, I dont see properties and print-name as belonging to this
categorie. Only value and function can be refered to by just using the
symbol.

Kind regards, alux


On Jan 3, 11:25 am, Gordon Guthrie <gor...@hypernumbers.com> wrote:
> A
>
> Ahah! So it is the sort of stuff I write about in lesson 2-4:http://learn-elisp-for-emacs.org/rsts/lesson-2-4.html
>
> Do you think there should be a little section there about
> Lisp-1/Lisp-2 and how they are different?
>
> Maybe use the (a a) example you suggest?
>
> Also in eLisp a symbol can have 4 properties :(
> * print name
> * variable name
> * function
> * property list
>
> Seehttp://www.gnu.org/software/emacs/emacs-lisp-intro/elisp/Symbol-Compo...

alux

unread,
Jan 3, 2011, 2:29:00 PM1/3/11
to learn-elisp-for-emacs
Btw,

here is an article "Why You should Not Use The Jargon Lisp1 and
Lisp2".

http://xahlee.org/emacs/lisp1_vs_lisp2.html

I agree with the gist that this difference is minor. It is just
something a beginner might be puzzled about. It is an interesting
fact, that this distinction gives a small difference in code, but
almost no one in the way to think about a Lisp, after you learned your
way.

kr a.
Reply all
Reply to author
Forward
0 new messages