[Pharo-project] UUID comparaison is Incorrect
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? 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
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
And I would rather like to see another implementation like < aMagnitude "Answer whether the receiver is less than the argument." (self size = aMagnitude size) ifFalse: [ ^ self size < aMagnitude size ]. 1 to: self size do: [:i | (self at: i) = (aMagnitude at: i) ifFalse: [ ^ (self at: i) < (aMagnitude at: i) ]]. ^false. Norbert 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?
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
Thanks norbert. You see this was a kind of exercise⦠to see if people can get a bit more involved. I could have simply introduce the fix but I want people to understand that there are a lot of little trivial things that can get done and it will help the system. So thank :) :) On Nov 5, 2011, at 11:20 AM, Norbert Hartl wrote:
And I would rather like to see another implementation like
< aMagnitude "Answer whether the receiver is less than the argument."
(self size = aMagnitude size) ifFalse: [ ^ self size < aMagnitude size ]. 1 to: self size do: [:i | (self at: i) = (aMagnitude at: i) ifFalse: [ ^ (self at: i) < (aMagnitude at: i) ]]. ^false.
Norbert
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?
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
participants (2)
-
Norbert Hartl -
Stéphane Ducasse