Hi Ladislav,

it wasn't really meant as a puzzle, just amusing. Yes, you're right:

>type? in o 'b
>== none!

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.

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.

'y was first defined in object o's context and then unset. It is known in
object o's context as an unset value. 

So when I go through the same step sequence globally (a .. c), 'y and 'z
are evaluated in the same way. If I go through the same step sequence in
the object 'o, 'y and 'z are treated different from each other.

a) I think it would be preferable if 'y and 'z were treated identical in
the object's context as well, like they are in the global context.
b) I think the preferable behavior would be for REBOL to return unset! for
in o 'z

as well as for 

in o 'y

instead of returning none for 

in o 'z

and 'y for 

in o 'y.

Opinions?


It would make objects more consistent within themselves and more consistent
with the way non-defined and unset values are treated globally.


>
>value? none
>== true
>
>Regards
>    Ladislav
>
>
>> Hi Jeff,
>>
>> you wrote:
>> >I wonder what Carl's thinking is
>> >about why words default to NONE in functions, and UNSET at the
>global
>> >and object contexts.  What's the deeper meaning?
>>
>> A few more fun samples, followed by a short comment:
>>
>> 1. Samples
>> >> f: func [arg [any-type!] ] [ print value? 'arg ]
>> >> f
>> false
>> >> f 1
>> true
>>
>> >> f: func [ /refine arg [any-type!] ] [ print value? 'arg ]
>> >> f
>> true
>> >> f/refine
>> false
>>
>> >> o: make object! [ a: none unset 'a ]
>> >> probe o
>>
>> make object! [
>>     a: unset
>> ]
>>
>> >> type? o/a
>> == unset!
>> >>
>>
>> >> in o 'b
>> == none
>> >> value? in o 'b
>> == true
>>
>> Of course. none is defined.
>> Wouldn't it be better is in o 'b returned unset! instead of
>none?
>>
>> >> in o 'a
>> == a
>> >> value? in o 'a
>> == false
>>
>> because 'a in o is defined as unset!.
>>
>> 2. Comment
>> Is it really a puzzle? As soon as arguments are used as part of
>a function
>> declaration, they have entered into a state of existence and
>must be
>> initialized to some none-value.
>>
>>
>>
>> At 11:23 AM 5/29/00 -0600, you wrote:
>> >
>> >>  [EMAIL PROTECTED] wrote:
>> >>> The trick here is what does  SELF evaluate to  when you set
>'x to
>> >>> it?  SELF at that time is an object, containing the words C
>and D,
>> >>> but those words haven't yet been assigned anything at the
>time you
>> >>> assign the word X to SELF.
>> >>
>> >>  I would assume they're unset in that stage (even if perhaps
>setting
>> >> them to NONE  could make more sense  for an object,  like  it
>is for
>> >> function contexts).
>> >
>> >  Which makes me consider what are the real distinctions
>between NONE
>> >and UNSET?  I tend to think that NONE, in REBOL, is closer to a
>> >logical state, where as UNSET is more of an existential state.
>For a
>> >function, local variables defaulting to NONE eases a common
>question
>> >function writers will ask in their code:
>> >
>> >   if local-variable [do-something-with local-variable]
>> >
>> >  I tend to think that words in the global context or in an
>object
>> >context are more in an existential state. Once they are
>mentioned in a
>> >given context the word exists but with no value.  They either
>are
>> >filled in by the person mentioning that word in that context or
>not.
>> >A word at the global context or in an object context isn't like
>a word
>> >in a function context which may be changing all the time, being
>passed
>> >in or not.  Those non function context variables seem more
>> >existential. At least, that's how it all strikes me.  But. of
>course,
>> >that's just my own formulation, and not necessarily the most in
>> >keeping with REBOL's philosophy.  I wonder what Carl's thinking
>is
>> >about why words default to NONE in functions, and UNSET at the
>global
>> >and object contexts.  What's the deeper meaning?  There always
>is a
>> >deeper purpose with most things in REBOL.  (-:
>> >
>> >  Cheers--
>> >
>> > -jeff
>> >
>> >
>> >
>> >
>>
>> ;- Elan >> [: - )]
>>
>>
>
>
>

;- Elan >> [: - )]

Reply via email to