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>
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