From: "Ben Tilly" <[EMAIL PROTECTED]>
Date: Thu, 26 Oct 2006 17:09:35 -0700
On 10/26/06, Bob Rogers <[EMAIL PROTECTED]> wrote:
> From: Tom Metro <[EMAIL PROTECTED]>
[...]
> Guido made comparisons to Perl only in two areas - saying he likes
> generators and iterators better than continuations . . .
>
> made me think of a paper [1] I only stumbled on recently (despite it
> being 13 years old!) on the semantic weaknesses of iterators. I found
> it while researching coroutines; I can think of no more compelling
> demonstration of the power of continuations than the fact that they make
> coroutines trivial to implement [2].
[...]
While I agree that continuations are insanely powerful, I likewise
prefer generators and iterators to continuations. Why? Well suppose
that you write some complex code using continuations. Suppose that
something goes wrong. Now you want to debug it. So you'd want some
useful debugging information. Something like, say, a stack backtrace.
You're outta luck.
That is not true -- or, at least, not necessarily true. In a full CPS
language like Scheme, tail-merging (or the equivalent CP transformation)
is obligatory, so you may in fact be of luck. (I've never used Scheme,
so I don't know how a real Schemer goes about debugging.) However, a
Scheme continuation looks just like a closure at the source level. It
is possible to write nearly identical code in Common Lisp that uses
closures, and since CL does not tail-merge by default, you get the same
functionality plus useful backtraces in the debugger.
Of course, you may also blow out the stack if you try to write
Scheme-style loops without tail-merging. But Common Lisp allows you to
enable tail-merging selectively, as a compiler optimization.
I also believe (from having written complex CL applications) that the
use of functional arguments (closures, continuations, whatever) reduces
complexity, sometimes considerably. This is a direct consequence of
Graham's "succinctness = power" thesis in [1], which Tom cited
previously.
Abstraction. Speed. Debuggability. Pick any three. ;-}
-- Bob
[1] http://www.paulgraham.com/power.html
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm