<br><br><div class="gmail_quote">On Sat, Oct 31, 2009 at 8:55 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;">
2009/10/31 Nicolas Cellier &lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>&gt;:<br>
&gt; 2009/10/31 Stéphane Rollandin &lt;<a href="mailto:lecteur@zogotounga.net">lecteur@zogotounga.net</a>&gt;:<br>
&gt;&gt;&gt;&gt; If the meaning of #isLiteral is to indicate that what is printed can be<br>
&gt;&gt;&gt;&gt; read back (i.e. will be correctly parsed) then I think it is a very useful<br>
&gt;&gt;&gt;&gt; message that we should keep.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; #isLiteral mainly indicates which objects can be created at compile time.<br>
&gt;&gt;&gt; They are literally inserted in the compiled method. This must match the<br>
&gt;&gt;&gt; syntax definition of Squeak. There is no question about not keeping it.<br>
&gt;&gt;<br>
&gt;&gt; now I&#39;m confused. are all objects anwering true to #isLiteral also have a<br>
&gt;&gt; printed form that can be read back ? should they ?<br>
&gt;&gt;<br>
&gt;&gt; Stef<br>
&gt;&gt;<br>
&gt;<br>
&gt; I think this is used as a feature at least in Decompiler.<br>
&gt;<br>
&gt; But can they all be read back ?<br>
&gt; Float can&#39;t always with the current implementation (they don&#39;t print exactly).<br>
&gt;<br>
&gt; (Compiler evaluate: Float halfPi printString) = Float halfPi<br>
&gt;<br>
&gt; Nicolas<br>
&gt;<br>
<br>
By the way, there is a workaround in CompiledMethod&gt;&gt;#=<br>
<br>
self isFloat ifTrue: [...]<br>
<br>
The #halt: in there sounds like calling for a better fix.<br>
For example, the workaround does not work with a literal Array of Float...<br></blockquote><div><br></div><div>Right.  It doesn&#39;t deal with NaNs either.  But it was good enough for my needs (checking that modifications to the compiler did or did not produce different compiled methods).  I could live with the false positive of Float class&gt;&gt;initialize.  One thing that could work here is to extend analogousCodeTo: to literals and then use it.  For Float it could compare the bit patterns except for NaN, and arrange that NaNs compare as equal, or it could compare the bit patterns so that different NaNs compare differently.  I suspect that comparing NaNs as equal is the right thing to do.  As far as execution goes one NaN should be as good as another right?</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Nor does it deal with infinity:<br>
(Float class compile: (Float class &gt;&gt; #initialize) decompileString<br>
                classified: nil<br>
                notifying: requestor<br>
                trailer: Float class defaultMethodTrailer<br>
                ifFail: [^nil]) method = (Float class &gt;&gt; #initialize)<br>
<br>
We have an excellent absPrintExactlyOn:base: that avoids extra digits<br>
when unnecessary...<br>
...but it is 3x to 10x slower and nobody dared generalizing its usage.<br>
<br>
{0.0. Float pi. Float pi   * 1.0e200. Float pi   * 1.0e-200 . 10.0 .<br>
0.1 . 237.128} collect: [:e |<br>
        [String streamContents: [:s | e absPrintExactlyOn: s base: 10]] bench<br>
        -&gt;[String streamContents: [:s | e printOn: s base: 10]] bench]<br>
<br>
{&#39;12131.77364527095 per second.&#39;-&gt;&#39;63358.65653738505 per second.&#39;.<br>
&#39;1535.292941411718 per second.&#39;-&gt;&#39;6756.64867026595 per second.&#39;.<br>
&#39;653.669266146771 per second.&#39;-&gt;&#39;6667.066586682664 per second.&#39;.<br>
&#39;1004.199160167966 per second.&#39;-&gt;&#39;5857.82843431314 per second.&#39;.<br>
&#39;8732.85342931414 per second.&#39;-&gt;&#39;26025.3949210158 per second.&#39;.<br>
&#39;8635.87282543491 per second.&#39;-&gt;&#39;19715.45690861827 per second.&#39;.<br>
&#39;2666.26674665067 per second.&#39;-&gt;&#39;13040.99180163967 per second.&#39;}<br>
<font color="#888888"><br>
Nicolas<br>
<br>
</font></blockquote></div><br>