[Cuis-dev] Inconsistent #= and #hash
Hernan Wilkinson
hernan.wilkinson at 10pines.com
Wed Jun 12 04:24:50 PDT 2019
>
> without trying that, I know that Interval fails for anything that is not a
> Number, not sure if should be fixed or not. What do you think?
>
A long time ago, when we implemented measures (Aconcagua) it was a surprise
to me that Interval only worked with numbers and not with objects that
define a total order, so we created ArithmeticObjectInterval that works for
any object that complies with the protocol defined in ArithmeticObject and
doing so, we could define intervals for measures, dates, years, and the
like.
You can see it in the Aconcagua packages.
Cheers!
Hernan.
>
>
>
> On Tue, Jun 11, 2019 at 5:25 PM Juan Vuletich <juan at jvuletich.org> wrote:
>
>> On 6/11/2019 8:49 AM, Luciano Notarfrancesco via Cuis-dev wrote:
>> > I did this to fish for inconsistencies:
>> >
>> > instances _ OrderedCollection new.
>> > Object withAllSubclassesDo: [:each| instances addAll: each
>> allInstances].
>> > instances _ instances asArray.
>> >
>> > 1 to: instances size do: [:i|
>> > a _ instances at: i.
>> > aHash _ a hash.
>> > i+1 to: instances size do: [:j|
>> > b _ instances at: j.
>> > (a = b and: [(aHash = b hash and: [b = a]) not]) ifTrue: [self
>> > halt]]]
>> >
>> > (I typed it manually here, I hope I copied it right, but you get the
>> > idea.)
>> >
>> > Found out this:
>> > - FeatureRequest forgets to implement hash;
>> > - #() = Semaphore new, but not the other way around, and hashes also
>> > differ;
>> > - similarly, LinkedList new = Semaphore new;
>> > - RunArray new = Object new fails because it assumes the argument is a
>> > Collection and sends isSequenceable;
>> > - RunArray new = Text new, but hashes differ;
>> > - Set new = Dictionary new but hashes differ;
>> >
>> > And there are more, I stopped before finishing.
>> >
>> > I don't know how to fix some of those, and the implications of
>> > changing the behavior of #= or #hash are not obvious in some cases.
>> > But I think we should change Collection>>hash to set the initial value
>> > to 0 instead of 'self species hash', and that would fix two of the
>> > issues above. What do you think? Other ideas?
>>
>> I just pushed fixes to most of them. For Semaphore and RunArray it is a
>> matter of implementing and honoring #species. For Set, it was making
>> aDictionary is: #Set to answer false. For the others it was adding a new
>> #hash or #= methods. I don't expect much breakeage.
>>
>> I'll run now a tweaked (hopefully faster) version of your script.
>>
>> 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
>>
>> --
> Cuis-dev mailing list
> Cuis-dev at lists.cuis.st
> https://lists.cuis.st/mailman/listinfo/cuis-dev
>
--
*Hernán WilkinsonAgile 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20190612/48e99906/attachment.htm>
More information about the Cuis-dev
mailing list