[squeak-dev] Re: [Pharo-project] Prune stack serialization

Juan Vuletich juan at jvuletich.org
Fri Dec 2 19:55:20 UTC 2011


Mariano Martinez Peck wrote:
>
>
> On Fri, Dec 2, 2011 at 8:30 PM, Juan Vuletich <juan at jvuletich.org 
> <mailto:juan at jvuletich.org>> wrote:
>
>     Eliot Miranda wrote:
>
>
>
>         On Fri, Dec 2, 2011 at 10:55 AM, Mariano Martinez Peck
>         <marianopeck at gmail.com <mailto:marianopeck at gmail.com>
>         <mailto:marianopeck at gmail.com <mailto:marianopeck at gmail.com>>>
>         wrote:
>
>            Thanks both. I am right to assume that if the block refers
>         to temp
>            vars, parameters, or whatever in another scope, then such
>         solution
>            won't work. I mean, if I have this example for example:
>
>            | bytes result blah |
>            blah := 42.
>            bytes := FLSerializer serializeToByteArray: (SortedCollection
>            sortBlock: [:a :b | (a + blah) > b ]).
>
>            Then the 'blah' is in a different context. So the mentioned
>            solution works for "clean" closures, which are "self
>         contained".
>            In the other cases (such as this example), we should
>         serialize the
>            whole stack. Is this correct?
>
>
>         No.  The closure implementation arranges that any and all
>         temporary variables accessed by the closure are directly
>         accessible from the closure without accessing the outer contexts.
>          ...
>
>
>     WRT clean closures, check what I did in Cuis to serialize
>     SortedCollections. See implementors and senders of #isClean.
>
>
> Nice. Thanks Juan. I was checking your code, and that's exactly why I 
> asked Eliot. In your method you say:
>
> isClean
>     "A clean closure is one that doesn't really need the home context 
> because:
>         - It doesn't send messages to self or super
>         - It doesn't access any instance variable
>         - It doesn't access any outer temp
>         - It doesn't do ^ return"
> .....
>
> So... my question is, WHAT do I need to serialize if I want to be able 
> to serialize also "non clean". I mean, for each item on that list, 
> what do I need apart from the closure instance and the receiver and 
> method from the outerContext ?  the whole stack of contexts ?
>

I think it is needed to know why you need to serialize a non-clean 
closure. If it is just to be able to evaluate it, maybe you don't need 
the stack at all. My trick could be augmented by serializing any 
referenced objects, but not the stack.

Cheers,
Juan Vuletich

>
> Thanks a lot in advance!
>
>
>
> -- 
> Mariano
> http://marianopeck.wordpress.com




More information about the Squeak-dev mailing list