[squeak-dev] Shift/reset old news

Frank Shearar frank.shearar at angband.za.org
Wed May 11 16:32:18 UTC 2011


On 2011/05/11 15:36, Tony Garnock-Jones wrote:
> On 2011-05-11 10:03 AM, Frank Shearar wrote:
>> http://source.lukas-renggli.ch/continuations.html
>> *sigh*
>> A nice suite, too: shift/reset, control/prompt, shift0, ...
>
> Heh :-) So will you be merging the two projects? Or would you recommend
> retiring one in favour of the other? Or something else?
>
> (I ask because I'm going to need a delimited-continuations package in
> the medium-term future, and I'd like to know where to look first :) )

The package certainly loads cleanly into a fresh trunk. Something 
strange is happening though, because running the tests a second time 
(the first generates a huge number of failures) hangs my image.

Once I've figured out what's going on I'll be able to comment properly, 
but for an ad hoc off-the-cuff:

Lukas is very clever, so his is probably better. His library has loads 
of operators, so if you want more than just shift/reset, try his out.

Control (mine/Levente's) implements only shift/reset, but the use 
thereof is quite natural. Also, I know that Control works properly, 
because I can get the tests to run :) One thing to watch out for though 
is that Control exposed a bug in Cog, so be sure to use a version later 
than r2380 (or use the Interpreter VM).

You can use the partial continuations in one of two ways:

   [ 1 + [:k | cont := k. k value: 0 ] shift ] reset
   [ 1 + [:k | k value: 2 ] shift ] reset

or (thanks to Levente)

   c := [ 3 + PartialContinuationNotification signal ]
      on: PartialContinuationNotification
      do: [ :not | not continuation ].
   c value: 4. "==> 7"

(The two ways just split the responsibilities of creating and invoking 
the continuations differently.)

frank



More information about the Squeak-dev mailing list