REBOL3 tracker
  0.9.12 beta
Ticket #0001124 User: anonymous

Project:



rss
TypeBug Statustested Date21-Jul-2009 22:07
Versionalpha 76 CategoryNative Submitted bySunanda
PlatformAll Severityminor Prioritynormal

Summary UNIQUE cannot handle unset
Description May be related to CC#1075

R2: is happy to handle unset in set operations:
>> unique reduce [unset 'a unset 'a]
== [unset]

R3: is not:
>> unique reduce [unset 'a unset 'a]
** Script error: unset! type is not allowed here

Which is odd as R3 is generally better at handling unset! than R2, eg:
mold unset 'a ;; R2: fails; R3: works

Issue extends to other set operations:
-- difference
-- exclude
-- intersect
Example code
unique reduce [unset 'a unset 'a]
difference reduce [unset 'a] []
exclude reduce [unset 'a] []
intersect reduce [unset 'a] []

Assigned ton/a Fixed inalpha 108 Last Update20-Oct-2010 03:24


Comments
(0001398)
Carl
22-Jul-2009 05:49

UNSET means "no value" -- it is difficult to determine if it should be allowed in such expressions.
(0001399)
Sunanda
22-Jul-2009 06:19

UNSET's handling is a little inconsistent in general.

***

It is a value you can search for, eg in both R2 and R3:
select reduce [1 2 unset 'a 3 ] unset 'a
== 3

And a basic SORT can handle it (again R2 and R3):
sort reduce [1 2 unset 'a 3 ]
== [unset 1 2 3]

But not a /compare SORT:
sort/compare reduce [1 2 unset 'a 3 ] func [a b] [return a < b]
** Script error: b has no value

***

RETURN and PRINT work with UNSET in R3, but not PRINT in R2:

r3: f: does [return unset 'a] print f
[prints blank line]

r2: f: does [return unset 'a] print f
** Script Error: print is missing its value argument

***

MOLD and LOAD is not possible in R2. R3 converts to a word:

r2: load mold unset 'a
** Script Error: mold is missing its value argument

r3: type? load mold unset 'a
== word!

(0001402)
BrianH
22-Jul-2009 09:07

Note that in your SORT/compare example, it is not the SORT that has a problem with unset!, it is the < in the compare function. Interestingly enough, you also prove that SORT/compare ignores the type spec of its comparison function, which should not allow unset arguments (probably a bug, but not necessarily a serious one).

In your last example you are mixing up MOLD with MOLD/all. The opposite of MOLD is DO. The opposite of MOLD/all is LOAD.

The PRINT change was intentional - see #562.

Date User Field Action Change
20-Oct-2010 03:24 BrianH Fixedin Modified => alpha 108
20-Oct-2010 03:24 BrianH Category Modified Unspecified => Native
20-Oct-2010 03:24 BrianH Status Modified problem => tested
22-Jul-2009 09:07 BrianH Comment : 0001402 Added -
22-Jul-2009 06:19 sunanda Comment : 0001399 Added -
22-Jul-2009 05:49 carl Status Modified reviewed => problem
22-Jul-2009 05:49 carl Comment : 0001398 Added -
22-Jul-2009 05:05 carl Description Modified -
22-Jul-2009 05:05 carl Code Modified -
22-Jul-2009 05:05 carl Status Modified submitted => reviewed
21-Jul-2009 22:07 sunanda Ticket Added -