On Oct 15, 2012, at 7:25 PM, Frank Shearar wrote:

> On 13 October 2012 17:05, Stéphane Ducasse <[email protected]> wrote:
>> Frank
>> 
>> I was asked to do a keynote to master, phd student and other and I would 
>> like to show them that with the right
>> tool we can do some powerful abstractions.
>> 
>> I'm thinking showing them
>>        thisContext use for haltIf
>>        on:fork: example
> 
> I don't see a #haltIf: in my Pharo 2.0 image (but it's well out of
> date, and I'm still waiting for the update to finish) but I imagine it
> would evaluate a block and when that block returns true, uses
> thisContext sender (sender ...) to drop you into the right context?

haltIf: condition

        ….


haltIfCallChainContains: aSelector

        | cntxt |
        cntxt := thisContext.
                [cntxt sender isNil] whileFalse: [
                        cntxt := cntxt sender. 
                        (cntxt selector = aSelector) ifTrue: [self signal]].



> 
>> do you have idea?
>> Should I look (I will ;)) look at Control and DynamicVariable?
>> Do you have other idea?
> 
> I think thisContext is an excellent jumping board into a great many
> things. 
> http://www.mirandabanda.org/cogblog/2009/01/14/under-cover-contexts-and-the-big-frame-up/
> has a lovely paragraph:
> 
> "Contexts are fabulous weapons, even better programming building
> blocks, and horribly expensive. How do I love contexts? Let me count
> the ways…
> 
> Contexts mean Smalltalk has had edit-and-continue debugging since the 1970′s.
> Contexts allow the implemention of an exception system with no
> additional support from the virtual machine.
> Contexts allow the implemention of dynamic binding, co-routines,
> tail-recursion-elimination and backtracking with no additional support
> from the virtual machine.
> Contexts enable process persistence and migration.
> Contexts allow implementation of continuations (full,
> delimited/partial or otherwise) without additional VM support (and
> hence the Seaside web framework).
> Contexts are consistent (consistent) with the rest of the “objects all
> the way down” system, providing activations as first-class objects.
> Because they’re there."

Yes I read that a while ago.
> 
> frank
> 
>> Stef
>> 
>> On Oct 13, 2012, at 5:54 PM, Frank Shearar wrote:
>> 
>>> On 13 October 2012 15:47, Damien Cassou <[email protected]> wrote:
>>>> I'm looking for a piece of code that is hard to understand by looking
>>>> at the source code but which has unit tests that help understanding
>>>> the behavior.
>>>> 
>>>> Do you have any idea?
>>> 
>>> http://ss3.gemstone.com/ss/Control/ has tests for delimited dynamic
>>> variables. The idea's not terribly complicated - close over a variable
>>> and use resumable exceptions to refer to it or change it - but if you
>>> don't have that in-a-nutshell idea in your head it can look a bit
>>> strange. But the tests in ControlTests' DelimitedDynamicVariableTest
>>> show quite clearly how dynamic binding works.
>>> 
>>> (The delimited part probably won't make a lot of sense until one's
>>> managed to wrap one's head around control operators - shift, in this
>>> case - so the nice interaction between the delimited continuations and
>>> the delimited dynamic variables might be lost on a newbie.)
>>> 
>>> frank
>>> 
>>>> --
>>>> Damien Cassou
>>>> http://damiencassou.seasidehosting.st
>>>> 
>>>> "Success is the ability to go from one failure to another without
>>>> losing enthusiasm."
>>>> Winston Churchill
>>>> 
>>> 
>> 
>> 
> 


Reply via email to