<br><br><div class="gmail_quote">On Fri, Dec 2, 2011 at 10:20 AM, Nicolas Cellier <span dir="ltr">&lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@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;">
2011/12/2 Martin Dias &lt;<a href="mailto:tinchodias@gmail.com">tinchodias@gmail.com</a>&gt;:<br>
<div><div></div><div class="h5">&gt; Hi folks<br>
&gt;<br>
&gt; In Fuel, we serialize a block closure with its state, including its<br>
&gt; outerContext. This enables to serialize a sorted collection with its<br>
&gt; sortBlock:<br>
&gt;<br>
&gt; | bytes result |<br>
&gt; bytes := FLSerializer serializeToByteArray: (SortedCollection sortBlock: [:a<br>
&gt; :b | a &gt; b ]).<br>
&gt; result := FLMaterializer materializeFromByteArray: bytes.<br>
&gt; result<br>
&gt; addAll: #(1 2 3);<br>
&gt; yourself.<br>
&gt; ---&gt; a SortedCollection(3 2 1)<br>
&gt;<br>
&gt; Here the problem: the byte array is huge! (800kb) because we are serializing<br>
&gt; unneeded context for the sort block.<br>
&gt;<br>
&gt; We wonder how to prune it and save time and space.<br>
&gt;<br>
&gt; Thanks in advance<br>
&gt; Martín<br>
<br>
</div></div>In the case of such clean block, there is no need of outer context<br>
during block execution.<br>
However I don&#39;t know if implementation makes it possible to ignore the<br>
context...<br>
That&#39;s more a question directed to Eliot ;)<br></blockquote><div><br></div><div>Arguably there is a bug in my closure implementation, which is that both the receiver and the method are fetched from the outerContext.  That&#39;s not a bug which can be fixed without a new VM/image combination and may be something I&#39;ll look at long-term, but is something we have to live with at the moment.  This means that you *do* have to serialize the outerContext.  But the outerContext is used only for the receiver and method.  So you don&#39;t need to full serialize the outerContext.  In particular you don&#39;t need to serialize any of the outerContext&#39;s stack contents or its sender.  This needs special handling, I guess in BlockClosure, to substitute a suitably reduced outerContext, but it shouldn&#39;t be hard to do.  e.g.</div>
<div><br></div><div>BlockClosure methods for: &#39;*Fuel-serialization&#39;</div><div>outerContextForSerialization</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>^MethodContext</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>sender: nil</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>receiver outerContext receiver</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>method: outerContext method</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>args: #()</div>
<div><br></div><div><br></div><div>BlockClosure methods for: &#39;*Fuel-serialization&#39;</div><div>outerContextForSerialization</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>^MethodContext</div>
<div><span class="Apple-tab-span" style="white-space: pre; ">                </span>sender: nil</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>receiver self receiver</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>method: self method</div>
<div><span class="Apple-tab-span" style="white-space: pre; ">                </span>args: #()</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<font color="#888888"><br>
Nicolas<br>
<br>
</font></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>