[Cuis-dev] Wired behavior for CompiledMethod>>#=

Juan Vuletich juan at jvuletich.org
Mon Mar 9 08:02:17 PDT 2020


On 3/5/2020 9:46 PM, Hernan Wilkinson via Cuis-dev wrote:
> Hi,
>  I just noticed that two methods that have the same source code but 
> are in different classes are considered equal... there is a comment in 
> the #= implementation that says that.
>  Why is that? what is the use case for that behavior?
>
>  I checked with Squeak and Pharo just for curiosity and they are 
> considered different...
>
>  Hernan.
>
> -- 
> *Hernán Wilkinson
> Agile Software Development, Teaching & Coaching*
> *Phone: +54-011*-4893-2057
> *Twitter: @HernanWilkinson*
> *site: http://www.10Pines.com <http://www.10pines.com/>*
> Address: Alem 896, Floor 6, Buenos Aires, Argentina

Hi Hernán,

Maybe that was done in 
2343-AvoidTestFailures-JuanVuletich-2015May27-15h25m-jmv.1.cs.st  . 
Maybe it was done before that. I don't remember.

The commet at the method reads
"#penultimateLiteral is selector (or properties, just compared, above)
     Last literal is #methodClass.
     Don't compare them. Two methods might be equal even if they have 
different selector (or none at all)
     or are installed in different classes (or none at all)"

Maybe at the time it was done, behavior was consistent with Squeak.

I tried changing it, by adding
self penultimateLiteral = method penultimateLiteral ifFalse: [ ^ false ].
self methodClass = method methodClass ifFalse: [ ^ false ].
and it doesn't make any test fail.

Maybe this behavior could be useful for a code rewrite tool, to check 
that the generated code stays the same, without needing to actually 
install the compiled method to be checked...

Cheers,

-- 
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
@JuanVuletich

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20200309/840935c2/attachment-0001.htm>


More information about the Cuis-dev mailing list