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

[REBOL] word Re:(4)

From: tim:johnsons-web at: 14-Aug-2000 14:56

Hi Elan: At 03:30 PM 8/14/00 -0700, you wrote:
>Hi Tim, > >1. memb is a global word in either case. > >2. > >> memb: 12345 >== 12345 > >> zzz: 87907 >== 87907 > >> memb: 343434 >== 343434 > >> index? find first system/words 'memb >== 1402 > >> index? find first system/words 'zzz >== 1403 > >Aha. > >It stands to reason that: >a) when REBOL parses the word memb it checks in its global wordlist for >memb. If memb is found there it must be associated with the value it is >being assigned. If memb is not found in the global wordlist, then >b) an entry must be created for memb, and then a) must be performed for >this new entry. > >In this scenario REBOL must do the same things it does for a previously >defined word memb, plus more, when it creates a new word memb. > >Therefore associating an existing word with a new value is cheaper than >creating a new word. > >This is true independend of whether you create the word outside the loop as >a separate step. If you did not previously create the word, and you create >the word in the loop, then the first time REBOL encounters the word in the >loop, it will be created (costly), and when it is encountered in the loop >again, it will be re-used (cheaper). > >All that is pure speculation and may be completely incorrect :-).
I'll take it on your authority that you are probably right. But, I just might make it a habit of creating words outside of loops. Always good to read your explanations of what is going on under the hood (my mother never could make me stop taking things apart!) Thanks :) Tim