This code snippet fails for the latest 5.0 build.
The failure only happens if the String instance and the DateTime/TimeSpan instance are created from the same value (here: "1").
Adding .DateTime~new(1) instead of .TimeSpan~new(1) will fail too.
Adding the same items to an IdentityTable (instead of Table), will work.
t = .Table~new
t[1] = 0
t[.TimeSpan~new(1)] = 0
(the issue may be related to the code fixes done for [bugs:#1365])
Anonymous
This is exactly related to the fixes for 1365 and is also a reason why it is a bad idea for the the == method to ever result in an error. Looks like 1365 needs a rethink.
As it is the DateTime/TimeSpan/File
compareTomethods, which raise the error, I suggest a fix such asWe also might change the DateTime/TimeSpan
hashCodemethods to use something liketimestamp~hashcode~bitxor(hh)(where hh is e. g.'80'xfor one and'C0'xfor the other class; or any other class-specific identifier) so that identical hashCodes will occur much less likely.Hmmm, I see. I think some documentation is warranted for the Orderable class outlining this as a recommendation. You might also want to added a default compareTo() method that implements a default ordering so that classes that implement orderable can delegate to the interface method in case of a type mismatch.
Note also that there is currently no guarantee that the value returned by indentityHash will always be a numeric value. It might be desirable to explicitly specify that is is.
Yes, a very nice idea. If we want to enable something like
if \other~isA(self~class) then forward class(super)in acompareTo()method, would we have to implement a default ordering in both Comparable and Orderable (i. e. make an actual implementation instead of an abstract method)? We really don't know whether the caller inherits from Orderable or from Comparable (or both), right?And, thinking about the
(self~identityHash - other~identityHash)~signit seems to me we could equally just simply always return 1 (or -1) ..Committed code fixes with revision [r11177]
Added test with revision [r11178]
Related
Commit: [r11177]
Commit: [r11178]
Fixed added test with revision [r11187]
Related
Commit: [r11187]
Added rexxref updates with revision [r11675]
rexxref already states that identityHash() returns a number
I believe all suggestions have been implemented/documented, except for one thing I didn't implement:
"DateTime/TimeSpan hashCode methods to use something like timestamp~hashcode~bitxor(hh) (where hh is e. g. '80'x for one and 'C0'x for the other class; or any other class-specific identifier) so that identical hashCodes will occur much less likely. "
So I'm closing this.
Related
Commit: [r11675]