<br><br><div class="gmail_quote">On Fri, Dec 2, 2011 at 5:13 PM, Eliot Miranda <span dir="ltr">&lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@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 class="im">On Fri, Dec 2, 2011 at 4:01 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">
Hi Juan,<br>
<br>
...<div><br>
<br>
<br>
    I can say that it does indeed work. But I&#39;d be really grateful if<br>
    Eliot took a good look at that code!<br>
<br>
<br>
There is a much better way, using InstructionStream&gt;&gt;<u></u>interpreetNextInstructionFor: which abstracts away from the bytecode encoding and allows one to simply use messages.  e.g. look at <br>
<br></div><div>
and (SortedCollection sortBlock: [:a :b| a compare: b caseSensitive: false]) sortBlock abstractBytecodes evaluates to<br>
<br>
an OrderedCollection(#<u></u>pushTemporaryVariable: #pushTemporaryVariable: #pushConstant: #send:super:numArgs:)<br>
<br>
So a check for clean blocks would check for a block&#39;s abstractBytecodes not including some particular set of banned messages (which I *think* is pushReceiver pushReceiverVariable: popIntoReceiverVariable: storeIntoReceiverVariable: methodReturnConstant: methodReturnReceiver methodReturnTop).<br>


<br>
e.g.<br>
<br>
isClean<br>
      ^(self abstractBytecodes intersection: #(pushReceiver pushReceiverVariable: popIntoReceiverVariable: storeIntoReceiverVariable: methodReturnConstant: methodReturnReceiver methodReturnTop)) isEmpty<br>
<br>
<br>
    Cheers,<br>
    Juan Vuletich<br>
<br>
<br>
<br>
<br></div>
-- <br>
best,<br>
Eliot<br>
<br>
</blockquote>
<br>
Thanks Eliot. However, it looks to me that this needs more tweaking. </blockquote><div><br></div></div><div>&lt;blush&gt;Damn right :)  I&#39;ve done zero testing.  It was just an example&lt;/blush&gt;</div><div class="im">
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
For instance, your method answers true for<br>
   [ xx size ] isClean<br>
and<br>
   [ ^ nil ] isClean<br>
while mine answers false for both. Maybe we could serialize non local returns using the Compiler (although we won&#39;t be able to return anywhere), but external variable acess is a problem.<br>
<br>
Will keep playing with this for a while...<br></blockquote><div><br></div></div><div>Can you (can I??) write some tests?  What&#39;s xx in the above?  Ah! [^nil] isn&#39;t clean in my code since it should be pc &lt;= end, not pc &lt; end!!  Try the attached...</div>
</div></blockquote><div><br></div><div>having played around with this some it strikes me we might want a method that checks whether a block refers only to block local variables and constants, or block locals, globals and constants.  Say BlockClosure&gt;&gt;isSqueakyClean ;)</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote">
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Cheers,<br><font color="#888888">
Juan Vuletich<br>
<br>
</font></blockquote></div><font color="#888888"><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>
</font></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>