[comp.lang.scheme] terminology question

net@tub.UUCP (Oliver Laumann) (08/20/90)

One point that distinguishes Scheme's continuations from Classic Lisp's
"catch" is that a continuation can be used "jump into" a function that
has already returned (i.e. that is not currently "active").

What is this property of a continuation called?  In an earlier article
it has been referred to as "upward funargs", but I have also seen
"downward continuations" as well as "upward continuations".  Which is
the correct term?

I have already heard the "upward/downard funargs" thing in other
contexts.  What is the etymology of this term (probably a question for
the Lisp "oldtimers"), and what exactly does it mean?

Regards,
--
Oliver Laumann     net@TUB.BITNET     net@tub.cs.tu-berlin.de     net@tub.UUCP

jeff@aiai.edinburgh.ac.UK (Jeff Dalton) (08/21/90)

> One point that distinguishes Scheme's continuations from Classic Lisp's
> "catch" is that a continuation can be used "jump into" a function that
> has already returned (i.e. that is not currently "active").
> 
> What is this property of a continuation called?  In an earlier article
> it has been referred to as "upward funargs", but I have also seen
> "downward continuations" as well as "upward continuations".  Which is
> the correct term?

People often say "first class continuations", but I think something
more is required to show they are recallable.  (Ie, after it's been
called once, either explicitly or inplicitly by a normal return, it
can be called again.)

> I have already heard the "upward/downard funargs" thing in other
> contexts.  What is the etymology of this term (probably a question for
> the Lisp "oldtimers"), and what exactly does it mean?

A "funarg" is a functional argument.  It's also a data structure.  In
order to get lexical scoping, a function object has to contain an
environment.  In Lisp 1.5, this was accomplished by having the value
of (FUNCTION f) be (FUNARG f a-list), where f was usually a lambda-
expression and a-list was the environment.

Later, for example in MacLisp, it was decided that maintaining an
a-list was too expensive and so some less general tricks were used
instead.  In particular, if variable values were kept on a stack (or a
stack was used for the old values in shallow binding), a function that
was going to be passed as an argument to another function (rather than
be returned) required only a pointer to the stack as an environment.
In MacLisp, (*FUNCTION f) evaluated to (FUNARG f stack-pointer).

This trick worked only in the downward direction, hence "downward
funarg".  An "upward funarg" was one that could be returned "up"
to a caller.

-- Jeff

gz@cambridge.apple.com (Gail Zacharias) (08/21/90)

In article <1466@tub.UUCP> net@tub.UUCP (Oliver Laumann) writes:
>One point that distinguishes Scheme's continuations from Classic Lisp's
>"catch" is that a continuation can be used "jump into" a function that
>has already returned (i.e. that is not currently "active").
>
>What is this property of a continuation called?

Indefinite extent.  Lisp catch tags have only dynamic extent.

--
Home: gz@entity.com or ...mit-eddie!spt!gz
Work: gz@cambridge.apple.com

dak@sq.sq.com (David A Keldsen) (08/22/90)

net@tub.UUCP (Oliver Laumann) writes:

>One point that distinguishes Scheme's continuations from Classic Lisp's
>"catch" is that a continuation can be used "jump into" a function that
>has already returned (i.e. that is not currently "active").

>What is this property of a continuation called?  In an earlier article
>it has been referred to as "upward funargs", but I have also seen
>"downward continuations" as well as "upward continuations".  Which is
>the correct term?

I'm not going to claim any absolute knowledge on this, and I haven't
been able to find a citation handy on whether these are up- or down-
wards continuations.  However, continuations with this property are
only possible in implementations where the "upwards funarg problem" has
been solved (more later on funargs).

>I have already heard the "upward/downard funargs" thing in other
>contexts.  What is the etymology of this term (probably a question for
>the Lisp "oldtimers"), and what exactly does it mean?

Funarg is just a synonym for what we call a procedure in scheme, or a
closure in other languages, i.e. a code-environment pair.  It stands
for FUNctional ARGument.  The "funarg problem" is making sure that
a functional argument (i.e. a function used as an argument) gets
the right environment when applied.

"Upward funarg" means applying a function in an environment lexically
outside of where it is defined.  "Downward funarg" means applying a
function in an environment inside the environment where it was defined,
but "deeper."

The "upwards funarg" problem is a little tough because if the environment
is stored on a calling stack, it is *gone* when the function is left.
This is why siod, for example, doesn't support upward-funarg continuations...
the jumpbuf that it uses is *gone*, as it is on the C stack.  It is unable
to completely "capture" the continuation.

Regards,
Dak
-- 
// David A. 'Dak' Keldsen      dak@sq.com or utai[.cs.toronto.edu]!sq!dak
// "A loaf of bread, a jug of wine, a big TV with a hi-fi VCR and a nice 
//  stereo, a full fridge, a microwave, a UNIX system, two phone lines, 
//  a high speed modem, and thou."  --Omar the Software Engineer

jinx@zurich.ai.mit.edu (Guillermo J. Rozas) (08/22/90)

    In article <1466@tub.UUCP> net@tub.UUCP (Oliver Laumann) writes:
    >One point that distinguishes Scheme's continuations from Classic Lisp's
    >"catch" is that a continuation can be used "jump into" a function that
    >has already returned (i.e. that is not currently "active").
    >
    >What is this property of a continuation called?

    Indefinite extent.  Lisp catch tags have only dynamic extent.

Not quite sufficient.  One can easily imagine continuations that have
indefinite extent but can only be used once.  Dan Friedman and Chris
Haynes wrote a paper about this, but I don't remember the title, etc.

I like to think of Scheme reified continuations as re-entrant.

chaynes@sunfish.cs.indiana.edu (christophe haynes) (08/24/90)

   Not quite sufficient.  One can easily imagine continuations that have
   indefinite extent but can only be used once.  Dan Friedman and Chris
   Haynes wrote a paper about this, but I don't remember the title, etc.

"Embedding continuations in procedural objects," ACM Trans.
Programming Languages and Systems, Vol. 9, No. 4 (1987), 582--598.
Our "on-shot" continuations were implemented using general
continuations.  Though they might be useful in speciallized
circumstances, they were offered primarily as a relatively simple
example of the continuation embedding technique.

   I like to think of Scheme reified continuations as re-entrant.

I do to.

colin@array.UUCP (Colin Plumb) (08/24/90)

In article <JINX.90Aug22120120@chamarti.ai.mit.edu> jinx@zurich.ai.mit.edu writes:
> I like to think of Scheme reified continuations as re-entrant.

This property does some interesting things to functionality.
Obviously,
(define (foo) (1))
Is strictly functional - it can be replaced by "1" wherever it appears.
Less obviously,
(define (bar x) (cons x 1))
is not a function, since it can be called like:
(let ((y (call/cc bar)))
     (if (= (cadr y) 1) ((car y) (cons (car y) 2)))
     (cadr y))
And it will have returned (<continuation> 2).  I find this behaviour
disturbing in some odd way.
-- 
	-Colin