Re: An Acceptable Lisp



On 2008-08-27, Pascal Costanza <pc@xxxxxxxxx> wrote:
Jon Harrop wrote:
Matthew D Swank wrote:
He also said:
"There should be a simple, easily implementable kernel to the Lisp. That
kernel should be both more than Scheme -- modules and macros -- and less
than Scheme -- continuations remain an ugly stain on the otherwise clean
manuscript of Scheme.

What's wrong with continuations?

They interact badly with side effects.

That's not an argument for leaving them out of a language.

Side effects interact badly with other side effects, yet decent programming
languages support side effects. :)

But there is still a salient point here. Continuations are not some quick fix
path to speculative, nondeterministing programming. A continuation allows the
program to jump back to some saved point in its execution. However, this saved
point doesn't save the entire machine state. It could be argued that the
continuation saves only some relatively uninteresting pieces of the machine
state: namely some entities like lexical variables which are defined in the
programming language. In real software, you have external state: open files,
external databases, hardware, connections to other processes, et cetera. In
recognition of this, Scheme gives you dynamic-wind. With this, you are supposed
to take on the responsibility of saving and restoring any aspect of the world
that should work together with the continuation. Good luck!

For instance, if, deeply in some code, it is assumed that a database
transaction is in progress, then whenever you temporarily escape out of that
code via a continuation, you have to roll back that transaction. You may never
go back to that point again, so the database has to be in a state as if that
code never executed. But if you resume the code via a continuation, you have
to restore the transaction to exactly what it was at that point prior to the
escape, so that this partially completed transaction can continue. This is not
a matter of just adding a liberal sprinking of dynamic-wind and crossing your
fingers.

The nice thing about ordinary dynamic control transfers (the kind which escape
from a dynamic scope and can never return, triggering once-only unwind-protect
cleanup), is that they can settle everything. If code bails in the middle of
an incomplete transaction, the unwind-protect rolls it back, and that is final.
There are no questions about what if that code is resurrected and wants to
finish the transaction, and where do you stick the information needed to be able to do that, and how do you represent it, etc.
.



Relevant Pages

  • Re: DBI v2 - The Plan and How You Can Help
    ... What I'd like *you* to do is make proposals for what a Perl 6 DBI API> should look like. ... you could probably easily support replaying the transaction in the ... Perl 6 will be able to serialise continuations and probably also coroutines, ... in a coroutine to automatically resume itself once the continuation is thaw'ed. ...
    (perl.dbi.users)
  • Re: Lexical scope vs. dynamic scope
    ... It seems to me that Scheme didn't include dynamic scoping because it's ... If you capture the current continuation somewhere in the dynamic extent of this with-open-file, and later invoke that continuation somewhere outside of that dynamic extent, you probably want to reopen that file at the correct position, or so. ... OK, admittedly a weird example, but dynamic-wind allows you to express capturing such behavioral aspects of the dynamic environment. ...
    (comp.lang.lisp)
  • Re: Why is Screamer not a good example for the inclusion of call/cc?
    ... > I strongly prefer Common Lisp over Scheme for many reasons, ... I am not sure you really understand what call/cc is giving you, ... instead you pass a continuation that ... your current continuation even when you aren't writing CPS code. ...
    (comp.lang.lisp)
  • Re: Making Lisp popular - can it be done?
    ... |> ex 4 Scheme has continuations, could your VM support them efficiently ...    the stack is hidden in the environments of the continuations ...    the user or a continuation reified by some ... How does your VM support abandonment of the ...
    (comp.lang.lisp)
  • Re: Was sind eigentlich Continuations?
    ... Stefan Matthias Aust schrieb: ... Eine Continuation wird von Sussmann/Steele dann als eine Funktion ... Dies ist die klassische Fakultätsfunktion in Scheme ...
    (de.comp.lang.java)