Is UNSET allowed normally as an argument?

Carl Sassenrath, CTO
REBOL Technologies
29-Aug-2007 14:25 GMT

Article #0100
Main page || Index || Prior Article [0099] || Next Article [0101] || 6 Comments || Send feedback

Currently in R3, you can type:

>> form ()
== "!unset?!"

This means FORM accepts UNSET as an argument. But, should it?

The definition of UNSET is the value of an variable or expression when it has no value.

For example, the unset variable below returns false when tested for a value:

>> value? 'a-variable
== false

In general, UNSET is intended to throw errors to avoid proceeding too far in evaluation without detecting the missing value.

Currently, in R3 UNSET is allowed as a value for any function argument. It can be seen here:

>> f: func [a] [print :a]
>> f ()
== "unset!"

So, UNSET is being passed as an argument to the function.

But, in R2, to pass UNSET, you had to explicitly specify it in the function's arguments:

f: func [a [integer! unset!]] ...


f: func [a [any-value!]] ...

This allows UNSET to be passed; otherwise, it will generate an error (and it is a useful error at the function interface level, because we can tell the user what is missing, as in "argument a has no value").

That seems like the correct behavior (R2)... but what are your thoughts on it?


Updated 24-Jun-2024 - Edit - Copyright REBOL Technologies -