<br><br><div class="gmail_quote">On Fri, Dec 2, 2011 at 11:33 AM, Mariano Martinez Peck <span dir="ltr"><<a href="mailto:marianopeck@gmail.com">marianopeck@gmail.com</a>></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 class="im">On Fri, Dec 2, 2011 at 8:18 PM, Mariano Martinez Peck <span dir="ltr"><<a href="mailto:marianopeck@gmail.com" target="_blank">marianopeck@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br><div class="gmail_quote"><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="gmail_quote"><div><br></div><div>Is this clear or as clear as mud?</div></div></blockquote></div><div><br>Much clear now. One last question. So far, then, I didn't find/think a scenario where serializing the whole stack (from a closure) make sense. So, if I just want to serialize a closure and be able to materialize it, then it is *never* necessary the whole stack, in all scenarios? or I am missing a case where the whole stack is needed? I am talking only about when serializing closures, because if I directly serialize a MethodContext, it may happen that I want the whole stack (like the example I showed in ESUG where I serialized the whole Debugger and then I continue debugging in another image). <br>
<br></div></div></blockquote></div><div><br>For example, would this work?<div><br><br>| bytes result blah |<br>
blah := 42.<br></div>bytes := FLSerializer serializeToByteArray: (SortedCollection sortBlock: [:a :b | (a + blah) > b. ^ blah ]).<br><br></div></div></blockquote></div><div><br>of course it doesn't make sense to do a return there. I was just an example, imagine another place where there is a blockclosure I want to serialize and there is a return inside. <br>
</div></div></blockquote><div><br></div><div>To be able to return one needs the sender of the home context (the context at the end of the outerContext chain). But note that if the block contains a return and one returns form it this is a "side-ways" return. The return isn't from the stack that invoked the block. So it is "dangerous". It might work, it might not. Caveat emptor. Note that if serializing contexts in applications like Seaside one obviously does want to serialize a portion of the stack. But here the application is knowledgeable enough to manage the (de)serialized contexts correctly (just as the system does when loading a snapshot, which is effectively full of serialized contexts).</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote"><div>
<br><br> </div><div><div></div><div class="h5"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><div>has the return something to do with this? <br>
<br>
Thanks<br><br><br></div><div><div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="gmail_quote"><div>Thanks!<br> </div><div><div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><div><div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>Thanks!<div><div></div><div><br><br><div class="gmail_quote">On Fri, Dec 2, 2011 at 7:41 PM, Eliot Miranda <span dir="ltr"><<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>></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>On Fri, Dec 2, 2011 at 10:20 AM, Nicolas Cellier <span dir="ltr"><<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>></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 <<a href="mailto:tinchodias@gmail.com" target="_blank">tinchodias@gmail.com</a>>:<br>
<div><div></div><div>> Hi folks<br>
><br>
> In Fuel, we serialize a block closure with its state, including its<br>
> outerContext. This enables to serialize a sorted collection with its<br>
> sortBlock:<br>
><br>
> | bytes result |<br>
> bytes := FLSerializer serializeToByteArray: (SortedCollection sortBlock: [:a<br>
> :b | a > b ]).<br>
> result := FLMaterializer materializeFromByteArray: bytes.<br>
> result<br>
> addAll: #(1 2 3);<br>
> yourself.<br>
> ---> a SortedCollection(3 2 1)<br>
><br>
> Here the problem: the byte array is huge! (800kb) because we are serializing<br>
> unneeded context for the sort block.<br>
><br>
> We wonder how to prune it and save time and space.<br>
><br>
> Thanks in advance<br>
> 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't know if implementation makes it possible to ignore the<br>
context...<br>
That's more a question directed to Eliot ;)<br></blockquote><div><br></div></div></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's not a bug which can be fixed without a new VM/image combination and may be something I'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't need to full serialize the outerContext. In particular you don't need to serialize any of the outerContext's stack contents or its sender. This needs special handling, I guess in BlockClosure, to substitute a suitably reduced outerContext, but it shouldn't be hard to do. e.g.</div>
<div><br></div><div>BlockClosure methods for: '*Fuel-serialization'</div><div>outerContextForSerialization</div><div><span style="white-space:pre-wrap">        </span>^MethodContext</div><div><span style="white-space:pre-wrap">                </span>sender: nil</div>
<div><span style="white-space:pre-wrap">                </span>receiver outerContext receiver</div><div><span style="white-space:pre-wrap">                </span>method: outerContext method</div><div><span style="white-space:pre-wrap">                </span>args: #()</div>
<div><br></div><div><br></div><div>BlockClosure methods for: '*Fuel-serialization'</div><div>outerContextForSerialization</div><div><span style="white-space:pre-wrap">        </span>^MethodContext</div>
<div><span style="white-space:pre-wrap">                </span>sender: nil</div><div><span style="white-space:pre-wrap">                </span>receiver self receiver</div><div><span style="white-space:pre-wrap">                </span>method: self method</div>
<div><span style="white-space:pre-wrap">                </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><span><font color="#888888">
</font></span></font></blockquote></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>
</font></span><br><br>
<br></blockquote></div><br><br clear="all"><br></div></div><font color="#888888">-- <br>Mariano<br><a href="http://marianopeck.wordpress.com" target="_blank">http://marianopeck.wordpress.com</a><br><br>
</font><br><br>
<br></blockquote></div></div></div><span><font color="#888888"><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>
</font></span><br><br>
<br></blockquote></div></div></div><span><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></div></div><span><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></div></div><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><br><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>