merits of Lisp vs Python

Paul Rubin http
Mon Dec 11 07:14:20 EST 2006


"Alex Mizrahi" <udodenko at users.sourceforge.net> writes:
>  PR> Which book?
> Paul Graham's "On Lisp".

Oh ok, someone mentioned that was online, and I just bookmarked it.
I'll look at it when I'm more awake.

> "Programming Languages:Application and Interpretation"
> Shriram Krishnamurthi
> Brown University
> 
> it's not Common Lisp but  Scheme though, but it's very interesting since it 
> shows how continuations can be used for better web programming.

Scheme probably makes more sense for this type of book--it's simpler than CL.

> most CL implementation do tail call optimization, unless you're running 
> debug mode -- in that case you'd prefer full stack.

I'd rather stick to what the CL standard says, rather than what some
implementation might happen to do.  CL does not guarantee TCO so these
code transformation schemes mustn't rely on it.

> optimizing language. i think it's called trampolined style.
> example can be found in PAIP book: interpreter of Scheme is implemented in 

This book doesn't seem to be online.  But anyway I think you mean,
compile the Scheme code into one giant CL function, which is no longer
really a clean mapping of Scheme to CL, it's just writing an
interpreter.  And I think that interpreter has to do its own
management of environments rather than letting the CL runtime do it.
So basically it says CL is turing-complete and can do everything,
which we already knew ;-).

> (defun drive-cps (cps-lambda)
>   (catch 'done
>     (loop for f = cps-lambda then (funcall f))))

Part of the problem I'm having with these examples is I don't know all
the different macros being used.  But I think I understand one part of
what was confusing me before: your call/cc macros depend on a
nonstandard feature of some CL implementations.  You can't write a
call/cc macro in standard CL--you instead have to write something that
transforms the entire program.

I think even with TCO though, you still can't do coroutines with CL
macros (but you can do them with real call/cc).  The point is that you
have to do something like TCO on calls that are not tail calls and
actually have to return.  You again have to transform the whole
program, not just expand a call/cc macro locally inside functions that
use it.



More information about the Python-list mailing list