[squeak-dev] Re: A possible Cog bug

Levente Uzonyi leves at elte.hu
Mon Apr 25 17:16:53 UTC 2011


On Mon, 25 Apr 2011, Frank Shearar wrote:

> On 2011/04/24 21:08, Levente Uzonyi wrote:

snip

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

Right. It's just feels more natural to use notifications. The above 
example is equivalent with:

c := [ 3 + [ :k | k ] shift ] reset.

I think the [ :k | k ] block just makes it harder to understand what 
the code actually does.

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

That's a bit easier to understand, but I still consider the names #shift 
and #reset unrelated to continuations.

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

Both of them is ok for me. :)

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

Agreed, the code can be further simplified by using existing methods.


Levente

>
> frank
>
>



More information about the Squeak-dev mailing list