-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 04, 2000 10:05 AM
To: [EMAIL PROTECTED]
Subject: [REBOL] [REBOL]Advice in using global values Re:

> As Rebol reads through a script, when it encounters begin-block symbol (
"[" ) it sets aside a special place (?) for any variables that are
subsequently defined. When Rebol encounters the corresponding end-block
symbol ( "]" ) all the variables in that special place are freed(?). So, to
keep the number of variables low, you want to insure that variables are
defined as late as possible, and freed as early as possible. The way to do
this is to divide your script into blocks ( "func" blocks ), and do not
introduce variables until you reach the block you need them.

It kinda works this way for locally defined words of a function, but not for
blocks in general.

For REBOL it's better though of as: any local definition of a word "masks"
the previous definition. The word isn't really "freed up" when the local
definition falls out of context. The word is still defined in system/words.
The very first time a word is referred to, it is immediately defined in
system/words with a value of unset!. If you assign a value (to a "new" word)
in a global context, this unset! is changed to the value. If you assign a
value (to a "new" word) in a local context - masking the previous value of
unset! - then fall out of that context, the value of the word reverts to
unset!.

If you work long enough in the same REBOL session - not just doing the same
thing over and over - you'll fill up system/words even though most of them
were defined as local variables which are out of context (and/or set to
unset!).

- Michael Jelinek

Reply via email to