Hi Elan,
your puzzle:
o: make object! [ a: none unset 'a ]
in o 'b
value? in o 'b
; shows something, that is a bit different. Look here:
type? in o 'a
== word!
type? in o 'b
== none!
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 >> [: - )]
>
>