[squeak-dev] #= ==> #hash issues
cunningham.cb at gmail.com
Fri Nov 16 05:52:32 UTC 2018
On Thu, Nov 15, 2018 at 5:36 PM Eliot Miranda <eliot.miranda at gmail.com>
> Hi Bert,
> On Thu, Nov 15, 2018 at 4:38 PM Bert Freudenberg <bert at freudenbergs.de>
>> Somehow I missed Eliot's version, but unsurprisingly he had exactly the
>> same idea (use "last" not "stop" for hash). I'd still think bitXor: is
>> preferable to bitOr, that is the standard way in almost all hash methods.
>> But ...
>> BUT: I forgot about the super fallback in #=. That makes this discussion
>> pretty much moot, because since
>> #(1 2 3) = (1 to: 3) "true"
>> is true, this must also be true:
>> #(1 2 3) hash = (1 to: 3) hash "must be true"
>> So the only proper fix IMHO is to remove #hash from Interval (or replace
>> it with ^super hash and a proper comment)
> We discussed this a couple of weeks ago. There is no need for
> #(1 2 3) = (1 to: 3)
> to be true.
> #(1 2 3) = #[1 2 3]
> isn’t true. And we have hasEqualElements:. So a more coherent approach
> is for the hack that makes intervals equal to arrays be discarded, and the
> hashes kept distinct.
And I agreed with you weeks ago, but looking at it closer, the code
specifically says Interval is a species of Array.
Interestingly, ByteArray, which is a subclass of ArrayedCollection, doesn't
set its species, so its species is ByteArray. Which is desirable.
If we change the Interval #species to not be array, then many things break
with Interval - most notably #select: and #collect:, so a major overhaul
would be in store for that part of the code.
In line with Bert's allusion, if we removed the super = call, then #= is no
longer associative between Interval's and Arrays:
(1 to: 3) = #(1 2 3) "false"
#(1 2 3) = (1 to: 3)" true"
So, I'm just fixing the Interval only part and punting on the issue between
Interval and Array for now.
>> - Bert -
> best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev