[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: why tail recursion matters and why Java isn't it, was Re: lispperformance was Re: problems with lisp

Guy Steele - Sun Microsystems Labs wrote:
>    To: Guy Steele - Sun Microsystems Labs <Guy.Steele@sun.com>
>    Cc: ll1-discuss@ai.mit.edu
>    Subject: Re: why tail recursion matters and why Java isn't it, was Re: lisp 
> performance was Re: problems with lisp
>    From: "Perry E. Metzger" <perry@piermont.com>
>    Date: 04 Sep 2003 14:38:48 -0400
>    User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2
>    Guy Steele - Sun Microsystems Labs <Guy.Steele@sun.com> writes:
>    > P.S. Yes, per Pascal Costanza, Common Lisp with proper tail
>    > recursion and call/cc WOULD be a better language.
>    Quick question -- was the decision to make CL have separate function
>    and variable bindings mostly for compatibility with mac lisp and lisp
>    machine lisp, or was it something deeper philosophically? I find
>    scheme's lisp 1 semantics almost always more comprehensible and easier
>    to use...
> I think compatibility was the strongest component in the
> decision, though there were some who preferred separate
> bindings on other grounds (ranging from mathematical tradition
> to the very pragmatic issue of wanting to be able to use
> LIST or EXP as a variable name).


In Scheme (Lisp-1), you can say something like (((f a) b) c), whereas in 
Common Lisp (Lisp-2) you would need to say (funcall (funcall (funcall (f 
a)) b) c). So a Lisp-1 is more convenient for a functional programming 
style. (Perhaps it's a bit unfortunate that Common Lisp has chosen the 
rather long name 'funcall' instead of going for something shorter.)

On the other hand, you can do the following in Common Lisp:

(defclass person ()
   ((name :accessor name :initarg :name)))

(setf p (make-instance 'person :name "Pascal"))

(with-accessors ((name name)) p

Note that at the same time, you can still pass around the accessors as 
first-class functions inside of with-accessors/with-slots blocks.

I don't know how to do this in, say, Swindle (Scheme/Lisp-1) without the 
need to choose different names for the slots and their accessors. So a 
Lisp-2 is more convenient for an object-oriented programming style.

Another repeatedly claimed advantage of Lisp-2 is that it reduces the 
need for macro hygiene. I am not quite sure yet whether this is really 
the case. It rather seems to me that neither Lisp-1 nor Lisp-2 have 
strong disadvantages.


Pascal Costanza               University of Bonn
mailto:costanza@web.de        Institute of Computer Science III
http://www.pascalcostanza.de  Römerstr. 164, D-53117 Bonn (Germany)