[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: CPS in Parrot (was: A plea for a new old language)
Dan and everyone,
I have read a portion of the thread and there seems to be tremendous
confusion.
John Clements has tried to explain it a bit, but I'll try again with
different words.
1. A programming language may offer a class of values called
"continuations".
Historically Landin's Iswim was the first design, Scheme was the first
real language
to make it "big" (for some definition of that). Dan is right when he
says that we
shouldn't think of them as plain functions and Scheme may have made a
mistake
there. (It would have been better off making vectors functions.) So
take a look at
SML/NJ's signature for reifying the continuation:
callcc -- creates an opaque continuation object and hands it over to
some function
throw -- is the only primitive operation that can consume such a
"thing" and do something
with it.
2. The implementation of a programming language may or may not be based
on
a transformation of source code into so-called continuation passing
style. Roughly speaking,
in this style every function is called in tail-position and consumes a
representation of the rest
of the computation i.e. a place to send its result to. To generate code
from there, you can
do all kinds of tricks and target a whole range of run-time
architectures:
SML/NJ is all heap-based
T was shifting things to the stack as much as possible
etc etc
3. Whether or not your language implementation uses CPS is irrelevant
to the question
of whether your programs can be described with them. Continuation is
just a fancy word
for "a representation of the rest of the computation from some point in
the execution."
4. If your language provides this class of continuations, your
implementation may or may not
rely on CPS. The two are entirely orthogonal issues. One concerns
language *design*, the
other is an implementation technique.
5. The Indiana school of thought has successfully taught hundreds and
thousands of
students how to use callcc-continuations (1) and how to implement
languages using CPS (2).
Yes, it is about teaching. In my experience, the worst one can do is
teach the "how to use" callcc
continuations (1) with an explanation of how cps-continuations (2)
work. This implementation
perspective of teaching programming is a disaster in this small issue
and in general, too.
-- Matthias Felleisen