<div class="gmail_quote">2011/7/19 Eliot Miranda <span dir="ltr"><<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>></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 class="im">On Tue, Jul 19, 2011 at 10:44 AM, Nicolas Cellier <span dir="ltr"><<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>></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;">
Hmm, there'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><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></div><div class="h5">
<div></div></div></div></div></blockquote><div><br>Not easy to tell, there are too many senders...<br>For example, #hasReportableSlip would report itself as bad-behaved if you redefine hasLiteral: to be thorough.<br>But it would be easy to fix by just using same trick as #isBlueBookCompiled (self messages incldues: ...)<br>
#(#doOnlyOnce: #halt #halt: #hottest #printDirectlyToDisplay #toRemove #personal #urgent #haltOnce #haltOnce: #haltIf: )<br> do: [:aLit | ((self hasLiteral: aLit) and: [self messages includes: aLit])<br> ifTrue: [^ true]].<br>
<br>There might be other quirks, like RB is using refersToLiteral: which is using hasLiteral: (non thorough).<br>Maybe we can just try and see...<br><br>Nicolas<br><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="gmail_quote"><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><font color="#888888"><br>Nicolas</font><div>
<div></div><div><br><br><div class="gmail_quote">2011/7/19 Eliot Miranda <span dir="ltr"><<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>></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"><<a href="mailto:sean@clipperadams.com" target="_blank">sean@clipperadams.com</a>></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->DateAndTime<br>
<br>
and got false, even though an "=" literal is indeed there.<br>
<br>
Why doesn't #hasLiteral: use #=?<br></blockquote><div><br></div></div><div>Well, the tricky thing with literals is that 0.0 = 0 and 'one' = #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: 'literals' stamp: 'eem 7/19/2011 09:19'!</div><div>hasLiteral: literal</div><div><span style="white-space: pre-wrap;">        </span>| litClass lit |</div>
<div><span style="white-space: pre-wrap;">        </span>"Answer whether the receiver references the argument, literal."</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: "exclude superclass + selector/properties"</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: 'private' stamp: 'eem 7/19/2011 09:20'!</div><div>hasLiteral: literal</div><div><span style="white-space: pre-wrap;">        </span>"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:"</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'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'll go ahead and commit the change to Squeak trunk. I'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></div></div><br><br clear="all"><br>-- <br>best,<div>Eliot</div><font color="#888888"><br>
</font><br><br>
<br></blockquote></div><br>