<br><br><div class="gmail_quote">On Tue, Jul 19, 2011 at 11:20 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;">
<br><br><div class="gmail_quote"><div class="im">2011/7/19 Igor Stasenko <span dir="ltr">&lt;<a href="mailto:siguctua@gmail.com" target="_blank">siguctua@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">

i&#39;d vote for keeping #== .<br>
<br>
Remember there was a discussion whether:<br>
<br>
&#39;abc&#39; == &#39;abc&#39;<br>
<br>
should answer true or false.<br>
<br>
And if it returns false, meaning that compiler doesn&#39;t bother to<br>
optimize literals used, then<br>
#hasLiretal:<br>
should also use #== .<br>
<br>
Also, suppose that<br>
<br>
aMethod hasLiteral: #DateAndTime-&gt;DateAndTime<br>
<br>
answers true.<br>
But method&#39;s literal holds a variable binding , but not association<br>
which you just created.<br>
And then if you try something like following:<br>
<br>
assoc := #DateAndTime -&gt; DateAndTime.<br>
(aMethod hasLiteral: assoc) ifTrue: [ assoc value: Foo ].<br>
<br>
it won&#39;t make any effect on method, since it using different object.<br>
So, many tools (especially refactoring ones) can be confused by this,<br>
if they using #hasLiteral: in combination with mutating/replacing<br>
those literals .<br>
<div><div></div><div><br></div></div></blockquote></div><div><br>Interesting case.<br>That probably means literalEqual: should be refined in Association<br>Association&gt;&gt;literalEqual: otherLiteral<br>    &quot;Variable bindings are literally equal only if identical, because they should preserve their identity.&quot;    <br>

    ^self == otherLiteral<br></div></div></blockquote><div><br></div><div>+1.</div><div> </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><div>
<br>
On 19 July 2011 19:52, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt; On Tue, Jul 19, 2011 at 10:44 AM, Nicolas Cellier<br>
&gt; &lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hmm, there&#39;s the tricky edge case:<br>
&gt;&gt;<br>
&gt;&gt; 0.5s2 = 0.5s3<br>
&gt;&gt; 0.5s2 class = 0.5s3 class.<br>
&gt;&gt;<br>
&gt;&gt; But they should be different literals.<br>
&gt;&gt; I think there is a test case for it.<br>
&gt;&gt;<br>
&gt;&gt; Same goes for arrays<br>
&gt;&gt;<br>
&gt;&gt; #( 0 ) = #( 0.0 )<br>
&gt;&gt;<br>
&gt;&gt; I think we defined a #literalEquals: or something like that to handle this<br>
&gt;&gt; kind of cases.<br>
&gt;<br>
&gt; Yes, indeed.  I can change this.  But before doing so does anyone else agree<br>
&gt; that the whole hasLiteral: hasLiteralThorough: is too heavy-weight and we<br>
&gt; should ditch hasLiteralThorough: and make hasLiteral: be thorough?  And I<br>
&gt; suppose more importantly does anyone disagree?<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; Nicolas<br>
&gt;&gt;<br>
&gt;&gt; 2011/7/19 Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Mon, Jul 18, 2011 at 2:40 PM, Sean P. DeNigris &lt;<a href="mailto:sean@clipperadams.com" target="_blank">sean@clipperadams.com</a>&gt;<br>
&gt;&gt;&gt; wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I tried:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;    aMethod hasLiteral: #DateAndTime-&gt;DateAndTime<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; and got false, even though an &quot;=&quot; literal is indeed there.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Why doesn&#39;t #hasLiteral: use #=?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Well, the tricky thing with literals is that 0.0 = 0 and &#39;one&#39; = #one but<br>
&gt;&gt;&gt; these are all different literals.  That said, it looks like a bug to me.  It<br>
&gt;&gt;&gt; should surely be<br>
&gt;&gt;&gt; !CompiledMethod methodsFor: &#39;literals&#39; stamp: &#39;eem 7/19/2011 09:19&#39;!<br>
&gt;&gt;&gt; hasLiteral: literal<br>
&gt;&gt;&gt; | litClass lit |<br>
&gt;&gt;&gt; &quot;Answer whether the receiver references the argument, literal.&quot;<br>
&gt;&gt;&gt; litClass := literal class.<br>
&gt;&gt;&gt; 2 to: self numLiterals - 1 do: &quot;exclude superclass + selector/properties&quot;<br>
&gt;&gt;&gt; [:index |<br>
&gt;&gt;&gt; lit := self objectAt: index.<br>
&gt;&gt;&gt; (litClass == lit class and: [literal = lit]) ifTrue: [^true]].<br>
&gt;&gt;&gt; ^false! !<br>
&gt;&gt;&gt; !Array methodsFor: &#39;private&#39; stamp: &#39;eem 7/19/2011 09:20&#39;!<br>
&gt;&gt;&gt; hasLiteral: literal<br>
&gt;&gt;&gt; &quot;Answer true if literal is identical to any literal in this array, even<br>
&gt;&gt;&gt; if imbedded in further array structure. This method is only intended<br>
&gt;&gt;&gt; for private use by CompiledMethod hasLiteralSymbol:&quot;<br>
&gt;&gt;&gt; | litClass lit |<br>
&gt;&gt;&gt; litClass := literal class.<br>
&gt;&gt;&gt; 1 to: self size do:<br>
&gt;&gt;&gt; [:index |<br>
&gt;&gt;&gt; (litClass == (lit := self at: index) class<br>
&gt;&gt;&gt; and: [literal = lit]) ifTrue: [^true].<br>
&gt;&gt;&gt; (Array == lit class<br>
&gt;&gt;&gt; and: [lit hasLiteral: literal]) ifTrue: [^true]].<br>
&gt;&gt;&gt; ^false! !<br>
&gt;&gt;&gt; I&#39;ve run all the tests in a trunk 4.2 before and after and making the<br>
&gt;&gt;&gt; above change makes no difference.  So I think I&#39;ll go ahead and commit the<br>
&gt;&gt;&gt; change to Squeak trunk.  I&#39;ll leave the Pharo folks to apply it there-in.<br>
&gt;&gt;&gt;  Files attached.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Thanks.<br>
&gt;&gt;&gt;&gt; Sean<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; --<br>
&gt;&gt;&gt;&gt; View this message in context:<br>
&gt;&gt;&gt;&gt; <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>
&gt;&gt;&gt;&gt; Sent from the Pharo Smalltalk mailing list archive at Nabble.com.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; --<br>
&gt;&gt;&gt; best,<br>
&gt;&gt;&gt; Eliot<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; best,<br>
&gt; Eliot<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
<br>
<br>
</div></div><font color="#888888">--<br>
Best regards,<br>
Igor Stasenko AKA sig.<br>
<br>
</font></blockquote></div></div></div><br>
<br><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>best,<div>Eliot</div><br>