Hi Elan,

> My question regarding this behavior:
>
> >> Wouldn't it be better if in o 'b returned unset! instead of
> >>none?
>
> What do you think?
>
> >From a pragramatical point of view, the none return value is
surely useful.
> You can easily determine if the word is defined in the object.

[L]
You are right, I prefer:

>> obj: make object! [a: 1]
>> found? in obj 'a
== true
>> found? in obj 'b
== false

If in obj 'b would return a value of type unset!, we would get:

found? in obj 'b
** Script Error: found? is missing its value argument.
** Where: found? in obj 'b

and

value? in obj 'b
** Script Error: value? is missing its value argument.
** Where: value? in obj 'b

OTOH, if in obj 'b would return the unset! value, we would get:
>> found? in obj 'b
== true

and

value? in obj 'b
== true

None of the above looks useful to me.

[/L]
>
> At the same time, because 'b is not defined in o, I think it
would be
> cleaner, if it behaved like 'a that was set to unset!.
>
> In the global context it does that:
>
> 1. z was never defined:
> >> unset 'z
> >> value? 'z
> == false
>
> 2. y is defined and then unset.
> >> y: none
> == none
> >> value? 'y
> == true
> >> unset 'y
> >> value? 'y
> == false
>
>
> 3. Summary:
> a) I unset a non-defined 'z, and tested 'z using value? The
result was false.
> b) I set 'y to a value, and value? 'y returned true.
> c) I unset 'y
> d) Because of c) both 'z and 'y responded in the same way to
value?.
>
>
> 4. In contrast, in an object, if I follow the same sequence of
steps:
>
> a) I unset 'z
> b) I set 'y to a value
> c) I unset 'y
>
> >> o: make object! [unset 'z y: none unset 'y ]
>
> then the two words y and z in the object's context respond
differently to
> value?.
>
> >> value? in o 'y
> == false
> >> value? in o 'z
> == true
>
> We know why 'z responds with true. As you pointed out, it's
because 'z was
> never defined in the context of the object 'o, therefore in o 'z
returns
> none, and none is a defined word.

[L]
Not exactly, in this case:

type? in o 'z
== none!

which is not a word.

If you liked to have consistent results, you should have left In
as it was and redefined Value? as follows:

value?: func [word [any-type!]] [
    {Returns True, if the argument is a word, that doesn't have a
value of unset! datatype}
    all [word? get/any 'word not unset? get/any :word]
]

To complete my thoughts:

I think, that the behaviour is not consistent - I mean function
args <-> words. The reason IMHO is, that the original designer's
intent was to have only one datatype representing no value -
namely None!. The problem was, that None! datatype was not found
useful for the test whether words have been set, as can be seen
below:

a: none

which surely suggests that 'a is being set.

An inconsistency can be found even with Unset!, because the
expression

set/any 'a ()

surely points at the fact, that 'a is being set. My point of view
is, that no Rebol datatype can be consistently used for the
testing, whether a word has been set. I mean, that the most
consistent way of unset words testing is to hide the Unset!
datatype and disallow users to use such values in scripts.

That means, that any kind of expression returning a value of
Unset! datatype should return error instead.

It is feasible only if:

    ()
    do []
    exit

and some other expressions evaluated to None and None werethe only
means to not supply an argument to a function.

These are just my thoughts on the subject, they could add some
consistency to Rebol, even simplify some scripts, IMHO, but could
break a lot of scripts, so it is not likely to see a change here.


Regards
    Ladislav

Reply via email to