[squeak-dev] Re: A possible Cog bug

Frank Shearar frank.shearar at angband.za.org
Mon Apr 25 09:49:07 UTC 2011


On 2011/04/24 21:08, Levente Uzonyi wrote:
> On Thu, 21 Apr 2011, Frank Shearar wrote:
>
>> 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:
>>
>
> snip
>
>> Comments welcome!
>
> I thought it's a bit easier to use notifications instead of control
> operators. Here's an example:
>
> c := [ 3 + PartialContinuationNotification signal ]
> on: PartialContinuationNotification
> do: [ :not | not continuation ].
> c value: 4. "==> 7"

This is much like shift/reset. Well, I mean, it's exactly the same thing 
expressed in a slightly different way: we're dividing the labours 
differently.

I had thought of perhaps embedding shift more deeply into the image, and 
putting it on Object>>#shift:

   c := [ 3 + self shift ] reset.

I didn't, for two reasons:
1. The literature uses the "pass the continuation as an argument" 
pattern, and I wanted to stick closely to that (at least at first), and
2. the "self" in the above has nothing at all to do with the 
computation. If you wanted to be _extra_ confusing you could say

   c := [ 3 + 4 shift ] reset.

Your method avoids this issue, of course.

It makes me wonder though. One could say this:

   c := [ 3 + CaptureContinuation here ] reset

> So I implemented it and uploaded it to
> http://leves.web.elte.hu/squeak/Control-ul.5.mcz .
 >
> I also refactored the
> code a bit.  Even though some Pharo folks always wanted to be able to use
> streams with OrderedCollection (which works in Squeak btw), it's kinda
> pointless thing to use #streamContents: with them, because
> OrderedCollections can grow by themselves, unlike Arrays or Strings.
> The code works, the tests are green, etc.

Thanks! Do you mind if I upload your changes to 
http://www.squeaksource.com/Control.html ? (Shall I add you as a 
developer to same?)

> But I wasn't happy with the results, because ContextPart already
> implements #copyTo: (which I think can also be simplified by removing
> BlockContext support), which can be used to serialize the stack. So I
> wrote the code, but it didn't work for some reason.
<snip>

How is it that I missed #copyTo:? I saw all the _other_ stack 
manipulating stuff! There is a LOT of seriously cool stuff in the image.

frank



More information about the Squeak-dev mailing list