[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: continuations in Scheme (was: Google Summer of Code 2011)
- From: David Kastrup <dak@...>
- Date: Tue, 22 Feb 2011 15:02:52 +0100
Alex Queiroz <email@example.com> writes:
> On Tue, Feb 22, 2011 at 10:36 AM, David Kastrup <firstname.lastname@example.org> wrote:
>> It is passed by reference. Only the references are actually maintained
>> in the call stack. Any changes to the list itself can't be rewound when
>> rereturning into a continuation.
> So you are confusing continuations with software transaction
> memory. Continuations are about first-class control, not data
> structures rollback and commit.
Local _scalar_ variables are "rolled back". This discrepancy is a
general trait of Lisp-like languages. With increasingly cleaner
language constructs (proper lexical bindings, proper closures, proper
continuations etc), it becomes more and more apparent that the
functional character of the language is not reflected into the behavior
of its data structures.
Lua is not all that different here. Strings are immutable (but not
really a first-class data structure), but tables as the only "real" data
structure are also entities that are passed by reference and the inner
state of which is not subject to scoping.
As a result, continuations in Scheme are normally either used for
demonstrating trivial examples, or as building blocks for other control
structures that don't actually manipulate data.
But the data implications for rereturning to a previously established
dynamic state are not used as a serious programming paradigm, like
stateful backtracking, as a chess program using alpha-beta pruning would