Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Limit on Globals?

 [1/8] from: tim::johnsons-web::com at: 6-Nov-2001 8:38


Hello All: I'm struggling with code bloat here<sigh>. I have a large application with a significant number of global words. 1)Does anyone have any ideas as to what would be a reasonable limit on the number of global words? 2)Is there an advantage to putting global words into an object? Thanks! -- Tim Johnson <[tim--johnsons-web--com]> http://www.johnsons-web.com

 [2/8] from: greggirwin:mindspring at: 6-Nov-2001 11:03


Hi Tim, << 1)Does anyone have any ideas as to what would be a reasonable limit on the number of global words? >> I don't know what the limit might be, though I would guess it can grow very large indeed. Someone from RT would have to speak to size and speed implications. << 2)Is there an advantage to putting global words into an object? >> Organization would be the key reason I think. As REBOL becomes more and more popular, and we start calling other people's scripts, keeping global conflicts down is going to be very important. --Gregg

 [3/8] from: ryanc:iesco-dms at: 6-Nov-2001 10:13


Tim Johnson wrote:
> Hello All: > I'm struggling with code bloat here<sigh>. > I have a large application with a significant number of global words. > > 1)Does anyone have any ideas as to what would be a reasonable limit > on the number of global words?
1903 by my test...
>> repeat i 40000 [
[ ctr: i [ set to-word to-string i i [ ] ** Internal Error: No more global variable space ** Where: to-word ** Near: to word! :value
>> ctr
== 1903
>> > > 2)Is there an advantage to putting global words into an object? >
I have not been able to find any performance gain whatsoever. I would say there is some advantage logistically, helping to avoid naming conflicts, code portability, and just a way to devide up your source into understandable chunks. In a large program, you may look into coding it in dialect at the higher levels. This would take care of most naming conflicts too. Once you have gotten to objects, dialecting is just around the bind. --Ryan

 [4/8] from: tim:johnsons-web at: 6-Nov-2001 10:11


Hi Ryan: That was a good tip: Below is session I ran (Core 2.5.0.4. on RH 6.0. 450 mhz/320 meg ram)
>> length? first system/words
== 1154
>> repeat i 40000[ctr: i set to-word to-string i i]
** Internal Error: No more global variable space ** Where: to-word ** Near: to word! :value
>> ctr
== 2939
>> length? first system/words
== 4094 hmmm! 1154 + 2939 = 4093 Do we have (kind of) the beginning of a memory managment strategy here? Can global words be "unloaded" Thanks tj On Tue, Nov 06, 2001 at 10:13:43AM -0800, Ryan Cole wrote:
> Tim Johnson wrote: > > Hello All:
<<quoted lines omitted: 28>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Tim Johnson <[tim--johnsons-web--com]> http://www.johnsons-web.com

 [5/8] from: allenk:powerup:au at: 7-Nov-2001 6:03


----- Original Message ----- From: "Tim Johnson" <[tim--johnsons-web--com]> To: <[rebol-list--rebol--com]> Sent: Wednesday, November 07, 2001 3:38 AM Subject: [REBOL] Limit on Globals?
> Hello All: > I'm struggling with code bloat here<sigh>. > I have a large application with a significant number of global words. > > 1)Does anyone have any ideas as to what would be a reasonable limit > on the number of global words? > 2)Is there an advantage to putting global words into an object?
Putting word in objects allows you to reuse those words in different contexts, so you don't have to keep making up new ones as you would if they were all global. Reusing words keeps the count down. Cheers, Allen K

 [6/8] from: larry:ecotope at: 6-Nov-2001 12:05


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. 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

 [7/8] 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
<<quoted lines omitted: 4>>
> 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

 [8/8] from: tim:johnsons-web at: 6-Nov-2001 14:30


On Wed, Nov 07, 2001 at 06:03:46AM +1000, Allen Kamp wrote:
> ----- Original Message ----- > From: "Tim Johnson" <[tim--johnsons-web--com]>
<<quoted lines omitted: 11>>
> contexts, so you don't have to keep making up new ones as you would if they > were all global. Reusing words keeps the count down.
Aha! Thanks Allen! tj
> Cheers, > > Allen K > > -- > To unsubscribe from this list, please send an email to > [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- Tim Johnson <[tim--johnsons-web--com]> http://www.johnsons-web.com

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted