Control handling primitives
started 11/20/2003; 5:40:31 AM - last post 5/31/2004; 1:34:32 AM
|
|
Andris Birkmanis - Control handling primitives
11/20/2003; 5:40:31 AM (reads: 838, responses: 10)
|
|
Didn't find any reference to cupto on LtU. Looking for prompt was doomed (sidenote: why can't language designers be more creative with names?).
Could anybody knowledgeable, please, compare the expressive power of different control handling primitives, such as:
call/cc
run / fcontrol
prompt / cupto
shift / reset (control?)
I learned already that both cupto and shift/reset are expressable with call/cc (http://pauillac.inria.fr/~remy/work/cupto/), and it looks to me that run/fcontrol differ from prompt/cupto only superficially (http://citeseer.nj.nec.com/sitaram93handling.html).
Also, call/cc is expressable with cupto.
What I could not find is whether call/cc is more expressive than shift/reset.
Also the intuitive notion of expressiveness, as was mentioned on LtU recently, is more than just emulation with local changes.
It would be great to hear subjective experiences of somebody who tried several approaches in the field.
Thanks.
|
|
Andris Birkmanis - Re: Control handling primitives
11/21/2003; 2:03:06 AM (reads: 805, responses: 2)
|
|
I forgot to cite partial continuations' paper, which mentions some of these control operators, as well as F, spawn and splitter (oh, some of these guys are really just beforementioned operators in disguise, I cant find a full overview of all of them in one paper).
|
|
Andris Birkmanis - Re: Control handling primitives
11/21/2003; 7:19:11 AM (reads: 800, responses: 1)
|
|
|
Andris Birkmanis - Re: Control handling primitives
11/21/2003; 7:31:53 AM (reads: 775, responses: 0)
|
|
The world is very small indeed, the author of this paper is also the author of (withdrawn) object system for Scheme.
The funny part is I read SRFI-20 for the first time just yesterday, and today I stumble upon his another paper.
Probably I needed to say Schemer's world is very small :-)
Ah, I am starting to usurp this thread, it's time to end here.
|
|
Ehud Lamm - Re: Control handling primitives
11/21/2003; 9:18:33 AM (reads: 796, responses: 0)
|
|
Actually a very interesting subject. We discussed a few of the relevant papers in the past (I am almost certain that Dorai's paper was mentioned here).
I don't have the time to delve into this at the moment, but let us know what you uncover.
|
|
Rici Lake - Re: Control handling primitives
11/21/2003; 10:36:52 AM (reads: 775, responses: 0)
|
|
You might want to take a look at Hayo Thielecke's recent paper contrasting exceptions and call/cc, see http://www.cs.bham.ac.uk/~hxt/research/htpapers.html
His 1999 paper "Using a continuation twice..." is also quite interesting (at least, to me).
But, theory aside, I too would be interested in hearing from anyone with practical experience.
|
|
Andris Birkmanis - Re: Control handling primitives
11/22/2003; 10:22:02 AM (reads: 734, responses: 1)
|
|
|
Ehud Lamm - Re: Control handling primitives
11/23/2003; 12:37:44 AM (reads: 721, responses: 0)
|
|
conversely, continuations in the absence of state cannot express exceptions (Section 4).
This statement intrigued me (any EOPL reader knows this ain't true), so I started reading this very interesting paper (more later). Let me clarify the quote Andris gave, with the following (also from Thielecke's paper):
When we say that first-class continuations cannot express exceptions (in the absence of state),
this is meant in the sense that callcc cannot express them. That should not be taken to imply
that there can be no continuation semantics of exceptions; rather, it merely states that such a
semantics does not factor over that of callcc . In fact, a continuation semantics for exceptions can
easily be defined by passing two continuations, the current one and one for the current exception
handler.
|
|
Ken Shan - Re: Control handling primitives
11/23/2003; 9:04:38 PM (reads: 633, responses: 1)
|
|
The part of the rundown that I know of:
- call/cc and abort can both be expressed in terms of shift and reset
- Danvy and Filinski (DIKU TR 89/12, page 3)
- shift/reset in terms of call/cc and state
- Filinski (POPL '94); see also the Scheme48 distribution
- control and prompt in terms of call/cc and state;
call/cc (and abort) in terms of control and prompt
- Sitaram and Felleisen (LSC '90)
(Errata at Usenet Message-ID: <6079@brazos.Rice.edu>)
- shift and reset in terms of control and prompt
- Easy: translate "reset" to "prompt" and
"shift f" to "control g. let f x = prompt (g x) in".
This is mentioned by Gunter, Rémy, and Riecke
(FPCA '95, the paragraph at the upper-right corner of page 4)
- control and prompt in terms of shift and reset
- The existence of such a translation is implied by the fact that
control and prompt as control effects are a monad, because
Filinski's "representing monads" result tells us how to simulate
any monad using shift and reset. But Gunter, Rémy, and Riecke
(same paragraph) seems unaware of such a translation. In any
case, I have just produced an explicit translation; it crucially relies on recursive types.
call/cc without state cannot express shift/reset; see Sitaram and Felleisen LFP '90.
|
|
Andris Birkmanis - Re: Control handling primitives
11/23/2003; 11:51:26 PM (reads: 619, responses: 0)
|
|
Excellent summary!
Now I am thinking about drawing a diagram of this category...
The category of control operators, morphisms being "expressable in terms of".
Only half-joking.
|
|
Andris Birkmanis - Re: Control handling primitives
5/31/2004; 1:34:32 AM (reads: 86, responses: 0)
|
|
Note that Christian Queinnec's paper addresses only sequential spawn, though spawn realizes its full power only in concurrent settings - see Subcontinuations by ROBERT HIEB and R. KENT DYBVIG.
Looks like I have to re-visit spawn, it looks more interesting in the light of concurrency requirements I would like to address...
|
|
|
|