Re: Relative merits of Lisp-1 vs. Lisp-2?
- From: Pascal Costanza <pc@xxxxxxxxx>
- Date: Tue, 30 May 2006 23:46:29 +0200
JesusWaffle@xxxxxxxxx wrote:
What are the relative merits of a Lisp-1 (one namespace for both
functions and variable) versus a Lisp-2 (one namespace for functions,
and one for variables)? I can think of the following:
For Lisp-1:
* No #'
* It's always clear what a name refers to; can't do potentially
confusing things like (foo foo)
* Somewhat simplified language description, somewhat simplified
implementation
For Lisp-2:
* Can't accidentially shadow function names (especially important for
safe non-hygienic macros)
* The size of the namespace is doubled, because you can reuse each
name twice
Looking at the above lists, I would tentatively choose Lisp-2, since
the arguments for Lisp-1 are mostly aesthetic, and the arguments for
Lisp-2 are quite practical. But, what do you think? Are there any items
you would add to the lists?
Googling for Lisp-1, Lisp-2 and Lisp-n in comp.lang.lisp gives you quite a lot of postings on this question.
A standard reference is http://www.nhplace.com/kent/Papers/Technical-Issues.html
I mostly agree with your assessment. But note that a functional programming style is somewhat more convenient with a Lisp-1. It's easier to express things like (((f x) y) z) whereas in a Lisp-2 you would have to say (funcall (funcall (f x) y) z). So if you have a strong preference for functional programming (or would like to explore it more deeply) you might want to try out a Lisp-1 (i.e., Scheme).
A very real use of reusing a name for different purposes is CLOS. In a class definition, it is quite common to give an accessor the same name as the slot it accesses, like this:
(defclass person ()
((name :accessor name)))
In a method for person, you can then easily distinguish between accessing a slot directly and accessing it via its accessor, like this:
(defmethod m ((p person))
(with-slots (name) p
... (name p) ... ; the accessor
... name ...)) ; the slot
The fact that a Lisp-2 seriously lessens the need for hygienic macros is indeed also important IMHO.
Pascal
--
3rd European Lisp Workshop
July 3 - Nantes, France - co-located with ECOOP 2006
http://lisp-ecoop06.bknr.net/
.
- Follow-Ups:
- Re: Relative merits of Lisp-1 vs. Lisp-2?
- From: Didier Verna
- Re: Relative merits of Lisp-1 vs. Lisp-2?
- From: Thomas F. Bur***
- Re: Relative merits of Lisp-1 vs. Lisp-2?
- From: JesusWaffle
- Re: Relative merits of Lisp-1 vs. Lisp-2?
- From: Pascal Bourguignon
- Re: Relative merits of Lisp-1 vs. Lisp-2?
- References:
- Relative merits of Lisp-1 vs. Lisp-2?
- From: JesusWaffle
- Relative merits of Lisp-1 vs. Lisp-2?
- Prev by Date: Re: xml and s-expression
- Next by Date: Re: Just can't hear enough about Cells?
- Previous by thread: Relative merits of Lisp-1 vs. Lisp-2?
- Next by thread: Re: Relative merits of Lisp-1 vs. Lisp-2?
- Index(es):