<br><br><div class="gmail_quote">On Tue, Jul 19, 2011 at 10:44 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;">
Hmm, there&#39;s the tricky edge case:<br><br>0.5s2 = 0.5s3<br>0.5s2 class = 0.5s3 class.<br><br>But they should be different literals.<br>I think there is a test case for it.<br><br>Same goes for arrays<br><br>#( 0 ) = #( 0.0 )<br>

<br>I think we defined a #literalEquals: or something like that to handle this kind of cases.<br></blockquote><div><br></div><div>Yes, indeed.  I can change this.  But before doing so does anyone else agree that the whole hasLiteral: hasLiteralThorough: is too heavy-weight and we should ditch hasLiteralThorough: and make hasLiteral: be thorough?  And I suppose more importantly does anyone disagree?</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><font color="#888888"><br>Nicolas</font><div><div></div><div class="h5"><br><br><div class="gmail_quote">2011/7/19 Eliot Miranda <span dir="ltr">&lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>&gt;</span><br>

<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><br><br><div class="gmail_quote"><div>On Mon, Jul 18, 2011 at 2:40 PM, Sean P. DeNigris <span dir="ltr">&lt;<a href="mailto:sean@clipperadams.com" target="_blank">sean@clipperadams.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">

I tried:<br>
<br>
    aMethod hasLiteral: #DateAndTime-&gt;DateAndTime<br>
<br>
and got false, even though an &quot;=&quot; literal is indeed there.<br>
<br>
Why doesn&#39;t #hasLiteral: use #=?<br></blockquote><div><br></div></div><div>Well, the tricky thing with literals is that 0.0 = 0 and &#39;one&#39; = #one but these are all different literals.  That said, it looks like a bug to me.  It should surely be </div>


<div><br></div><div><div>!CompiledMethod methodsFor: &#39;literals&#39; stamp: &#39;eem 7/19/2011 09:19&#39;!</div><div>hasLiteral: literal</div><div><span style="white-space:pre-wrap">        </span>| litClass lit |</div>
<div><span style="white-space:pre-wrap">        </span>&quot;Answer whether the receiver references the argument, literal.&quot;</div><div><span style="white-space:pre-wrap">        </span>litClass := literal class.</div>
<div><span style="white-space:pre-wrap">        </span>2 to: self numLiterals - 1 do: &quot;exclude superclass + selector/properties&quot;</div><div><span style="white-space:pre-wrap">                </span>[:index |</div>
<div><span style="white-space:pre-wrap">                </span>lit := self objectAt: index.</div><div><span style="white-space:pre-wrap">                </span>(litClass == lit class and: [literal = lit]) ifTrue: [^true]].</div>
<div><span style="white-space:pre-wrap">        </span>^false! !</div><div>!Array methodsFor: &#39;private&#39; stamp: &#39;eem 7/19/2011 09:20&#39;!</div><div>hasLiteral: literal</div><div><span style="white-space:pre-wrap">        </span>&quot;Answer true if literal is identical to any literal in this array, even </div>


<div><span style="white-space:pre-wrap">        </span>if imbedded in further array structure. This method is only intended </div><div><span style="white-space:pre-wrap">        </span>for private use by CompiledMethod hasLiteralSymbol:&quot;</div>


<div><br></div><div><span style="white-space:pre-wrap">        </span>| litClass lit |</div><div><span style="white-space:pre-wrap">        </span>litClass := literal class.</div><div><span style="white-space:pre-wrap">        </span>1 to: self size do: </div>


<div><span style="white-space:pre-wrap">                </span>[:index | </div><div><span style="white-space:pre-wrap">                </span>(litClass == (lit := self at: index) class</div><div><span style="white-space:pre-wrap">                </span>and: [literal = lit]) ifTrue: [^true].</div>


<div><span style="white-space:pre-wrap">                </span>(Array == lit class</div><div><span style="white-space:pre-wrap">                </span> and: [lit hasLiteral: literal]) ifTrue: [^true]].</div><div><span style="white-space:pre-wrap">        </span>^false! !</div>


</div><div><br></div><div>I&#39;ve run all the tests in a trunk 4.2 before and after and making the above change makes no difference.  So I think I&#39;ll go ahead and commit the change to Squeak trunk.  I&#39;ll leave the Pharo folks to apply it there-in.  Files attached.</div>

<div>
<div><br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">

<br>
Thanks.<br>
Sean<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://forum.world.st/Why-does-CompiledMethod-hasLiteral-use-tp3676573p3676573.html" target="_blank">http://forum.world.st/Why-does-CompiledMethod-hasLiteral-use-tp3676573p3676573.html</a><br>




Sent from the Pharo Smalltalk mailing list archive at Nabble.com.<br>
<br>
</font></blockquote></div></div><br><br clear="all"><br>-- <br>best,<div>Eliot</div><font color="#888888"><br>
</font><br><br>
<br></blockquote></div><br>
</div></div><br><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>best,<div>Eliot</div><br>