Shift/reset old news

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Shift/reset old news

Frank Shearar
http://source.lukas-renggli.ch/continuations.html

*sigh*

A nice suite, too: shift/reset, control/prompt, shift0, ...

frank

Reply | Threaded
Open this post in threaded view
|

Re: Shift/reset old news

Tony Garnock-Jones-3
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 :) )

Regards,
   Tony

Reply | Threaded
Open this post in threaded view
|

Re: Shift/reset old news

Frank Shearar
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

Reply | Threaded
Open this post in threaded view
|

Re: Shift/reset old news

Levente Uzonyi-2
On Wed, 11 May 2011, Frank Shearar wrote:

> 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.)

For the note, I added ContextPart >> #copyTo:bottomContextDo: to the
Trunk which is a really simple and fast way to create partial
continuations (it requires the current latest CogVM r2382, or any
interpreter VM). ContextPart >> #copyStack is perfect for regular
continuations. I also reimplemented PartialContinuation (and
WAContinuation and WAPartialContinuation) with this method. I uploaded it
to the Control repository: http://squeaksource.com/Control/Control-ul.7.mcz
IIRC the rewrite of the Seaside continuations resulted in 1.16x speedup
for WAPerformanceFunctionalTest using Cog.


Levente

>
> frank
>
>