Come on, this is not a problem for UUIDs where all digits are the same. So just fix the commentI was thinking that we should get the same bug for you UUIDbecause 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?
StefBegin forwarded message:From: Alan Knight <knight@acm.org>Subject: Re: [vwnc] UUID Sorting IncorrectDate: November 1, 2011 3:19:23 PM GMT+01:00To: Runar Jordahl <runar.jordahl@gmail.com>Cc: vwnc@cs.uiuc.eduReply-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