[squeak-dev] Direct implementation of shift/reset in Smalltalk

Frank Shearar frank.shearar at angband.za.org
Thu Apr 21 11:50:50 UTC 2011


I finished a preliminary version of the shift/reset control operator for 
creating and using partial continuations:

http://www.squeaksource.com/Control.html

It's pretty easy to use:

[ 1 + 2 ] reset => 3
[ 1 + [:k | 2 ] shift ] reset => 2 (because k's not used, that part of 
the stack's discarded)
[ 1 + [:k | k value: 2 ] shift ] reset => 3
[ 1 + [:k | k value: (k value: 2) ] shift ] reset => 4
[ 1 + [:k | cont := k. k value: 0 ] shift ] reset => 1, and cont now 
holds the continuation, for later (re-)use.

It probably has horrific bugs and will eat your machine. It does, 
however, have as full a test suite as I can imagine, the execution of 
which, at least, does not eat your machine!

I wrote a reasonable walk-through of the library [1] that also mentions 
good starting points in the literature on the subject of 
partial/delimited/composable continuations.

I wrote the library with two intentions - firstly, that I could 
understand partial continuations and, secondly, to try provide a common 
vocabulary for working with partial continuations.

Comments welcome!

frank

[1] 
http://www.lshift.net/blog/2011/04/20/direct-implementation-of-shiftreset-in-smalltalk



More information about the Squeak-dev mailing list