Hi Klaus,<br><br><div class="gmail_quote">On Mon, Mar 9, 2009 at 11:04 AM, Klaus D. Witzel <span dir="ltr">&lt;<a href="mailto:klaus.witzel@cobss.com">klaus.witzel@cobss.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
On Mon, 09 Mar 2009 19:02:27 +0100, Eliot Miranda wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Mon, Mar 9, 2009 at 1:23 AM, Klaus D. Witzel wrote:<br>
</blockquote>
...<div class="im"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
You may perhaps also want to check the attachment from Mantis #7311 that I<br>
created a minute ago:<br>
<br>
- <a href="http://bugs.squeak.org/view.php?id=7311" target="_blank">http://bugs.squeak.org/view.php?id=7311</a><br>
<br>
This .st has 61 tests which I&#39;ve written for Marcus&#39; NewCompiler project<br>
(testing sourceCode -&gt; Parser -&gt; nodes -&gt; compiled method -&gt;<br>
InstructionStream). Made a small change for adapting them to your passing<br>
EncoderForV3 to the parser. BTW: all green in the recent<br>
Squeak-3.10.2-Closures.image ;)<br>
</blockquote>
<br>
Cool!  But TBH let&#39;s add a little yellow:<br>
<br>
testInlineBlockCollection1<br>
| col |<br>
col := OrderedCollection new.<br>
1 to: 11 do: [ :each | col add: [ each ] ].<br>
self assert: (col collect: [ :each | each value ]) asArray = (1 to: 11)<br>
asArray<br>
<br>
testInlineBlockCollection2<br>
| col |<br>
col := OrderedCollection new.<br>
1 to: 11 do: [ :each | | i | i := each. col add: [ i ]. i := i + 1 ].<br>
self assert: (col collect: [ :each | each value ]) asArray = (2 to: 12)<br>
asArray<br>
</blockquote>
<br></div>
Yellow, right, and they belong into ClosureCompilerTest. But they also raise questions:<br>
<br>
I&#39;ve seen that one of the differences between the Encoder*XYZ&#39;s is #supportsClosureOpcodes being true/false but also #generateAsClosure plays a role. So the *Closures suffix is short for *EmitClosuresBytecode? Also, blocks are never emitted the old (non-closure) way?</blockquote>
<div><br></div><div>The scheme is that by choosing the encoder one can choose the type of code generated.  So that e.g. if you say</div><div><br></div><div><div>(Parser new</div><div><span class="Apple-style-span" style="white-space: pre; ">        </span>encoderClass: EncoderForV3PlusClosures;</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>parse: someString readStream class: MyClass)</div><div><span class="Apple-style-span" style="white-space: pre; ">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>generate: #(0 0 0 0)</div>
<div><br></div><div>you&#39;ll get closure code and if you say</div><div><br></div><div><div><div>(Parser new</div><div><span class="Apple-style-span" style="white-space: pre; ">        </span>encoderClass: EncoderForV3;</div><div>
<span class="Apple-tab-span" style="white-space: pre; ">        </span>parse: someString readStream class: MyClass)</div><div><span class="Apple-style-span" style="white-space: pre; ">        </span><span class="Apple-tab-span" style="white-space: pre; ">        </span>generate: #(0 0 0 0)</div>
<div><br></div><div>you&#39;ll get pre-closure old-block code.</div><div><br></div><div>#supportsClosureOpcodes and #generateAsClosure are private internal messages various parts fo the compiler send to itself to bring this about.  Encoder implements supportsClosureOpcodes to say if the concrete class is designed to produce closure code.  BlockNode implements #generateAsClosure  to tell clients whether it was created as a block node for a closure or for an old-style block.<br>
</div><div><br></div><div><br></div></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">If they where (under whatever *config*, blocks emitted the old way) then both tests can only fail, that&#39;s why I ask.</blockquote>
<div><br></div><div>And on the wrong VM it&#39;ll crash.  Only the CLosure VM that people are providing right now can run both new and old code.  The StackVM we have in Qwaq (that I hope will be released sometime) will only run Closure code and die horribly if given old block code.</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">/Klaus</font><div><div></div><div class="h5"><br>
<br>
-- <br>
&quot;If at first, the idea is not absurd, then there is no hope for it&quot;. Albert Einstein<br>
<br>
<br>
</div></div></blockquote></div><br>