shift/reset

Dave Herman <[email protected]>
Newsgroups gmane.comp.lang.sml.smlnj
Message-ID <[email protected]>
I would love to see shift and reset make it into SML. Their types are 
well understood, and theoretically they shouldn't be too much harder to 
implement than callcc. Of course, this depends on the runtime system's 
representation of continuations.

It's possible to implement them in user code via Filinski's approach [1] 
with callcc and a ref cell, but this does not interact correctly with 
exceptions. Specifically, applying `shift' should discard only the 
exception handlers installed after/below the delimiter, and applying a 
saved continuation should not discard any exception handlers in the 
evaluation context of the application. Filinski's implementation doesn't 
do this. [2]

I was thinking about trying to hack at the SML compiler to see if I 
could figure out how to start implementing them myself, but it's pretty 
daunting. I started by trying to see how callcc is implemented, but it 
appears to be pretty deeply baked into the compiler. Any hints?

Thanks,
Dave

[1] http://citeseer.ist.psu.edu/filinski94representing.html
[2] For example, the following program should produce 42 but with 
Filinski's implementation it raises an uncaught exception:

     reset (fn () =>
                (shift (fn k => (k 1) handle Fail _ => 42))
                    + (raise Fail "foo"))


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.