Am 04.11.2011 um 21:13 schrieb Stéphane Ducasse:
I was thinking that we should get the same bug for you UUID because the code right now is
< aMagnitude "Answer whether the receiver is less than the argument."
1 to: self size do: [:i | (self at: i) < (aMagnitude at: i) ifTrue: [^true]]. ^false.
|a b| a := UUID fromString: '0608b9dc-02e4-4dd0-9f8a-ea45160df641'. b := UUID fromString: 'e85ae7ba-3ca3-4bae-9f62-cc2ce51c525e'. (a > b) = (b > a)
returns true and this looks wrong :)
What do you think?
Come on, this is not a problem for UUIDs where all digits are the same. So just fix the comment "Answer whether any digit of the receiver is less than the digit of the argument at the same position." done! Norbert
Stef
Begin forwarded message:
From: Alan Knight <knight@acm.org> Subject: Re: [vwnc] UUID Sorting Incorrect Date: November 1, 2011 3:19:23 PM GMT+01:00 To: Runar Jordahl <runar.jordahl@gmail.com> Cc: vwnc@cs.uiuc.edu Reply-To: knight@acm.org
Thanks. Created AR 64162
Runar Jordahl 25 October, 2011 7:13 AM
Class UUID is included in beta in VisualWorks 7.8. It seems like #< is implemented incorrect. If you evaluate the statement below it answers true:
|a b| a := UUID fromString: '0608b9dc-02e4-4dd0-9f8a-ea45160df641'. b := UUID fromString: 'e85ae7ba-3ca3-4bae-9f62-cc2ce51c525e'. (a > b) = (b > a)
The fix is to change the method to this:
< aMagnitude "Answer whether the receiver is less than the argument. Add an initial size check, in anticipation of greater than 128-bit Smalltalk-specific UUID type."
| ss ms |
ss := self size. ms := aMagnitude size. ss < ms ifTrue: [^true] ifFalse: [ ss > ms ifTrue: [^false] ifFalse: [ 1 to: self size do: [:i | (self at: i) < (aMagnitude at: i) ifTrue: [^true]. (self at: i) > (aMagnitude at: i) ifTrue: [^false]]. ^false]]
Runar Jordahl blog.epigent.com _______________________________________________ vwnc mailing list vwnc@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
_______________________________________________ vwnc mailing list vwnc@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/vwnc