Slobodan Blazeski <firstname.lastname@example.org> wrote:
| email@example.com (Rob Warnock) wrote:
| > ... such as the "linear Lisp" Henry Baker has written about at
| > great length, see: ...[examples]...
| > and several others. See his archive page:
| > http://home.pipeline.com/~hbaker1/
| Could linear lisp support continuations?
I'm not an expert in either linear logic or linear Lisp, but
from a brief look at Baker's papers, I'd have to say probably
"yes, sort of", but not usefully in the ways Scheme programmers
would normally expect. Consider this excerpt [with apologies if
I've in any way distorted the meaning by eliding]:
'Use-Once' Variables and Linear Objects -- Storage Management,
Reflection and Multi-Threading
Henry G. Baker (1994)
A 'use-once' variable must be dynamically referenced exactly
once within its scope. Unreferenced use-once variables must be
explicitly killed, and multiply-referenced use-once variables
must be explicitly copied; this duplication and deletion is
subject to the constraint that some linear datatypes do not
support duplication and deletion methods.
For example, use-once variables allow for the safe/controlled
use of reified language implementation objects like single-use
Continuations can be linear (enabling an efficient implementation,
unlike [Lincoln92]), since they normally return only once ("one-shot"
[Haynes87]), even when doing co-routining and time-sharing [Wand80].
(Prolog-like backtracking [Haynes87] requires expensive copying--if
allowed--or (non-linear) sharing of continuations.) Of course, a
linear call/cc can have no implicit continuation--the only way to
return from a linear call/cc is to invoke the passed continuation,
so a function which does not escape via a passed continuation must
return it for its caller's use. Escaping via a continuation kills
an implicit continuation thereby causing intermediate linear variables
to be finalized a la Common Lisp unwind-protect.
So, yes, you can have linear continuations, but they won't behave
like default (non-linear) Scheme multi-use continuations.
p.s. In the presence of linear variables, non-linear (Scheme-style)
continuations also violate the "one-use" guarantee of linear variables,
since invoking a continuation captured between the definition of a
linear variable and its single use (single reference) would cause
the variable to be referenced again. Oops.
Rob Warnock <firstname.lastname@example.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607