REBOL3 tracker
  0.9.12 beta
Ticket #0001150 User: anonymous

Project:



rss
TypeIssue Statusreviewed Date26-Jul-2009 20:08
Versionalpha 76 CategoryNative Submitted bySunanda
PlatformAll Severityminor Prioritynormal

Summary SORT order changed for datatypes
Description May be related to CC#415. And may be a deliberate break in compatibility with R2 that is worth documenting:

R2:
sort reduce [1 2 3 unset!]
== [unset! 1 2 3]

R3:
sort reduce [1 2 3 unset!]
== [1 2 3 unset!]
Example code

			

Assigned ton/a Fixed in- Last Update18-Jun-2010 01:55


Comments
(0001426)
BrianH
26-Jul-2009 20:33

This is related to #415, but in a surprising way.

There is no sensible answer to the question of whether 1 is less than #[unset!] - the concept simply doesn't apply. The most REBOL can hope to do is to just pick an answer. The answer R3 picked is that when the datatypes of the values are different, the datatypes are compared instead. The result is that the order follows the sorting order of datatypes: The order that the datatypes are listed in system/catalog/datatypes. I expect that R2 also followed this model, but had a different order of datatypes.

This is probably not even an error, but I've marked it as an Issue since this clearly needs some documentation.
(0001429)
Sunanda
26-Jul-2009 20:58

There's a further, related, issue:

MAXIMUM-OF in R3 is a mezzanine and error!s on:
maximum-of reduce [1 2 3 unset!]
That is perhaps acceptable behavior if such values are incommensurate.

But in R2, MAXIMUM-OF is a native. And (I guess) uses the same internal method that SORT does when comparing disparate data types. It does not fail (or not in the same way as R3 :-):
maximum-of reduce [1 2 3 unset!]
== [3 unset!]


****

The wider issue perhaps is:
Which of the lines of code below should:
a) fail
b) return a consistent result
c) return the same consistent result as R2


sort reduce [unset! 1]
unset! > 1
unset! = 1
maximum-of reduce [unset! 1]
(0001431)
BrianH
26-Jul-2009 21:18

That is because of this:
>> greater? () 1
** Script error: greater? does not allow unset! for its value1 argument

Or more precisely, this:
>> () > 1
** Script error: the comparison is not valid

Those errors are proper and, especially the latter one, descriptive. R2 *not* failing is arguably an error.
(0002394)
Ladislav
18-Jun-2010 01:55

My opinion is, that we should not mistake #[datatype! unset!] (in the description) with #[unset!]

Date User Field Action Change
18-Jun-2010 01:55 Ladislav Comment : 0002394 Added -
26-Jul-2009 21:18 BrianH Comment : 0001431 Added -
26-Jul-2009 20:58 sunanda Comment : 0001429 Added -
26-Jul-2009 20:33 BrianH Comment : 0001426 Added -
26-Jul-2009 20:14 BrianH Description Modified -
26-Jul-2009 20:14 BrianH Category Modified Unspecified => Native
26-Jul-2009 20:14 BrianH Status Modified submitted => reviewed
26-Jul-2009 20:14 BrianH Type Modified Bug => Issue
26-Jul-2009 20:08 sunanda Ticket Added -