The following method looks complicated for me. Do you know if it is still valid in latest Cog ?<br>Thanks :)<br><br><br>eliotsClosureMeasurementsOn: m over: aFiveArgBlock<br>    &quot;<br>    See senders.<br>    Or try something like:<br>
        Smalltalk<br>            eliotsClosureMeasurementsOn: FileList &gt;&gt; #defaultContents<br>            over: [ :closuresCount :hasCopiedValuesForClosure :hasIndirectTemps :anyClosureHasCopied :anyClosureDoesUAR :anyClosureUsesSelf |<br>
                (Array with: closuresCount with: hasCopiedValuesForClosure with: hasIndirectTemps with: anyClosureHasCopied with: anyClosureDoesUAR with: anyClosureUsesSelf)]<br><br>    From <a href="http://www.mirandabanda.org/cogblog/2008/11/14/mechanised-modifications-and-miscellaneous-measurements/">http://www.mirandabanda.org/cogblog/2008/11/14/mechanised-modifications-and-miscellaneous-measurements/</a><br>
    by Eliot Miranda<br>    &quot;<br>    | s nextScanStart thisClosureHasCopied closuresCount hasIndirectTemps blkPc blkSz anyClosureHasCopied anyClosureDoesUAR anyClosureUsesSelf analyzedClosures |<br>    closuresCount := 0.<br>
    hasIndirectTemps := false.<br>    anyClosureHasCopied :=  anyClosureDoesUAR := anyClosureUsesSelf := false.<br>    s := InstructionStream on: m.<br>    s scanFor: [ :b |<br>        b = 16r8F &quot;16r8F = 143 closure creation&quot; ifTrue: [<br>
            closuresCount := closuresCount + 1].<br>        (b = 16r8A &quot;16r8A = 138indirect temp vector creation&quot; and: [ s followingByte &lt;= 127]) ifTrue: [<br>                hasIndirectTemps := true].<br>        false].<br>
    nextScanStart := m initialPC.<br>    analyzedClosures := 0.<br>    [ analyzedClosures &lt; closuresCount ] whileTrue: [<br>        s pc: nextScanStart; scanFor: [ :b | b = 16r8F ].    &quot;16r8F = 143 Search for first closure&quot;<br>
        analyzedClosures := analyzedClosures + 1.<br>        thisClosureHasCopied := s followingByte &gt;= 16r10.<br>        anyClosureHasCopied := anyClosureHasCopied | thisClosureHasCopied.<br>        blkSz := s interpretNextInstructionFor: BlockStartLocator new.        &quot;Findout size of first closure&quot;<br>
        blkPc := s pc.<br>        s scanFor: [ :b |<br>            s pc &gt;= (blkPc + blkSz)<br>                ifTrue: [<br>                    nextScanStart := s pc.<br>                    true]<br>                ifFalse: [<br>
                    b = 16r8F ifTrue: [            <br>                        thisClosureHasCopied := s followingByte &gt;= 16r10.<br>                        anyClosureHasCopied := anyClosureHasCopied | thisClosureHasCopied.<br>
                        analyzedClosures := analyzedClosures + 1 ].<br>                    anyClosureDoesUAR := anyClosureDoesUAR or: [s willReturn and: [s willBlockReturn not]].<br>                    anyClosureUsesSelf := anyClosureUsesSelf or: [b = 16r70 &quot;pushSelf&quot;<br>
                                        or: [b &lt; 16r10 &quot;pushInstVar&quot;<br>                                        or: [(b = 16r80 and: [s followingByte &lt;= 16r3F]) &quot;pushInstVar&quot;<br>                                        or: [(b between: 16r60 and: 16r60 + 7) &quot;storePopInstVar&quot;<br>
                                        or: [(b = 16r82 and: [s followingByte &lt;= 63]) &quot;storePopInstVar&quot;<br>                                        or: [(b = 16r81 and: [s followingByte &lt;= 63]) &quot;storeInstVar&quot;<br>
                                        or: [b = 16r84 and: [s followingByte = 160]]]]]]]].<br>                    false]]].<br>    ^aFiveArgBlock valueWithArguments: (Array<br>            with: closuresCount<br>            with: hasIndirectTemps<br>
            with: anyClosureHasCopied<br>            with: anyClosureDoesUAR<br>            with: anyClosureUsesSelf)<br><br><div class="gmail_quote">On Fri, Dec 2, 2011 at 9:40 PM, Mariano Martinez Peck <span dir="ltr">&lt;<a href="mailto:marianopeck@gmail.com">marianopeck@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br><br><div class="gmail_quote"><div><div class="h5">On Fri, Dec 2, 2011 at 8:30 PM, Juan Vuletich <span dir="ltr">&lt;<a href="mailto:juan@jvuletich.org" target="_blank">juan@jvuletich.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Eliot Miranda wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
<br>
<br>
On Fri, Dec 2, 2011 at 10:55 AM, Mariano Martinez Peck &lt;<a href="mailto:marianopeck@gmail.com" target="_blank">marianopeck@gmail.com</a> &lt;mailto:<a href="mailto:marianopeck@gmail.com" target="_blank">marianopeck@gmail.com</a>&gt;<u></u>&gt; wrote:<br>


<br>
    Thanks both. I am right to assume that if the block refers to temp<br>
    vars, parameters, or whatever in another scope, then such solution<br>
    won&#39;t work. I mean, if I have this example for example:<br>
<br>
    | bytes result blah |<br>
    blah := 42.<br>
    bytes := FLSerializer serializeToByteArray: (SortedCollection<br>
    sortBlock: [:a :b | (a + blah) &gt; b ]).<br>
<br>
    Then the &#39;blah&#39; is in a different context. So the mentioned<br>
    solution works for &quot;clean&quot; closures, which are &quot;self contained&quot;.<br>
    In the other cases (such as this example), we should serialize the<br>
    whole stack. Is this correct?<br>
<br>
<br>
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.<br></div>
 ...<br>
</blockquote>
<br>
WRT clean closures, check what I did in Cuis to serialize SortedCollections. See implementors and senders of #isClean.<br>
<br></blockquote></div></div><div><br>Nice. Thanks Juan. I was checking your code, and that&#39;s exactly why I asked Eliot. In your method you say:<br><br>isClean<br>    &quot;A clean closure is one that doesn&#39;t really need the home context because:<br>

        - It doesn&#39;t send messages to self or super<br>        - It doesn&#39;t access any instance variable<br>        - It doesn&#39;t access any outer temp<br>        - It doesn&#39;t do ^ return&quot;<br>.....<br>

<br>So... my question is, WHAT do I need to serialize if I want to be able to serialize also &quot;non clean&quot;. 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 ?<br>

<br><br>Thanks a lot in advance!</div></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br>
<br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br><br>