[squeak-dev] Three questions

Frank Shearar frank.shearar at gmail.com
Sat Aug 4 08:17:46 UTC 2012


On 4 August 2012 08:51, Mateusz Grotek <unoduetre at poczta.onet.pl> wrote:
> Eliot Miranda pisze:
>> On Sun, Jul 29, 2012 at 7:56 AM, Mateusz Grotek <unoduetre at poczta.onet.pl>wrote:
>>
>>> Hi
>>> I have the following 3 questions:
>>> 1. Why there is ContextPart>>releaseTo: ? What will happen if I don't
>>> use it?
>>>
>>
>> releaseTo: simulates the effect of doing a method return from a block, i.e.
>> when a return exits more than the top context.  It sends singleRelease to
>> each context exited, which sets the pc and sender to nil (and nils the
>> stack, but this is excess to requirements).  releaseTo: is actually used
>> when a method return from a block encounters an unwind-protect and control
>> passes up to the image to run the unwind.  You don't need to use it.  It is
>> used automatically as part of running unwinds.  In what situation do you
>> think you do need to use it?
>>
>>
> I'm trying to implement backtracking as described in the paper:
> "Building a backtracking facility in Smalltalk without kernel support"
> by W. LaLonde and M. Van Gulik
>
> They commented their use of releaseTo: in this way:
>
> "aContext releaseTo: oldContext
> Release (by setting the temporaries in the context stack to nil) all
> contexts from the receiver, its sender, its sender's sender etc. up to
> but excluding oldContext. It is a superflous method that helps the
> garbage collector."
>
> I wondered if this is an artifact of the version of Smalltalk they used
> when writing the paper, or it really helps the garbage collector in some
> way. As far as I understand it contexts are collected just like normal
> objects, when there are no references to them. So i don't see a point in
> using this method, but I'm not an expert and maybe i miss something, so
> I asked this question.

You might be interested in a little library I wrote for delimited
continuations (which is what LaLonde/Van Gulik are effectively
implementing): http://ss3.gemstone.com/ss/Control.html. If I recall
correctly, Chung-chieh Shan's "Shift to Control" paper shows
backtracking implemented via success and failure continuations, just
like in LaLonde/Gulik.

frank

> Thank you for the anwer.
>


More information about the Squeak-dev mailing list