[REBOL] Re: forever loops inside view
From: gjones05:mail:orion at: 24-May-2001 5:37
From: "Chris Wright"
<snip>
> btw, am I right in suggesting that face variables scope to the top
level:
> l: layout [
> t: text "Fred"
> ]
>
> t/text: "Bill"
>
> seems to work...what are the scoping rules for face variables?
<snip>
Hi, Chris,
Cyphre (aka Richard Smolak) handled the first question. You are correct
in regard to the scope of the face variables ("words" in the REBOL
lexicon). In your example above, adding "show t" following the setting
of t/text to "Bill" will update the face.
To limit the scope, one must embed the layout within an object *and*
then set the face name within that context. For example:
my-lo: make object! [lo: layout [t1: text "goodbye"]]
view/new my-lo/lo
t1/text: "hello"
show t1
allows t1 to be accessible from the global scope, as was true in your
example. However, setting t1 to none within the object then makes that
word local to that context. Consider:
my-lo: make object! [t1: none lo: layout [t1: text "hello"]]
view/new my-lo/lo
t1/text: "hello" ;does not affect face
show t1 ;does not affect face
This example now does not affect the face. To reset the face text from
the global context, now one must use the path notation, such as:
...
my-lo/t1/text: "Goodbye"
show my-lo/t1
For larger programs, this method helps one to keep the namespaces
separate.
This discussion may have covered more than you were really asking, but
you would eventually be asking the additional questions, so ...
Hope this helps.
--Scott Jones