[REBOL] Re: Limit on Globals?
From: ryanc:iesco-dms at: 6-Nov-2001 13:02
Larry Palmiter wrote:
> Hi Tim, Ryan,
>
> Just a couple of quick comments on 'global' words (those listed in first
> system/words).
>
> 1) Every token in the source code which scans as a valid REBOL word is added
> to the global words. It makes no difference whether the word occurs in the
> local context of an object. In fact, even asking if a word is in first
> system/words will cause it to be added because the code is scanned and
> loaded before any evaluation occurs.
Thanks Larry, I definitely learned something. I also discovered that you can
check the system words without adding the word your looking for this way...
>> foreach wd first system/words [if "gazooks" = to-string wd [print wd] ]
== none
>> 'gazooks
== gazooks
>> foreach wd first system/words [if "gazooks" = to-string wd [print wd] ]
gazooks
>>
However, this example does add the word 'wd.
>
> 2) There is no way to remove global words. They accumulate in any REBOL
> session until the limit (currently 4094) is reached.
>
> 3) It is good to remember that a given word can be used in many contexts,
> referring to a different value in each context. A coding style which reuses
> variable names is less likely to result in reaching the limit on words.
>
> -Larry
>
Therefore...
>> repeat i 40000[ctr: i set to-word to-string i context [a: b: c: d: 44]]
** Internal Error: No more global variable space
** Where: to-word
** Near: to word! :value
>> ctr
== 1903
>>
1902 words each referencing a different object that holds 4 unique words, for a
total of 9510 uniquely contexted words added. This also demonstrates that
set-words dont count.
Thanks for your words on words Larry, very enlightening.
--Ryan