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

[REBOL] Re: intersting side-effect to dynamic word usage...

From: rotenca:telvia:it at: 16-Nov-2001 20:34

Hi, Media
> > 'foo is the value of 'fx, not a field of the GC. > > ok, but then What is it used for!?
Only as a shortcut to 'foo.
> The example I submitted also did that, in the sense that I'm using a word > in a block.. The monitor explicitely shows that the word isn't added until > the to-set-word call...
Yes. Or Load or To-xxx-path (first token) or To-xxx-word, or Do with a string/file/url, because it makes a inner call to Load.
> is it possible to then create objects on-the-fly without their attributes > ending up in the GC as set (or unset) words in system/words ?
Yes, it already was in my example, here it is another one: myObject: context to-block "attribute: 3"
> And then, is it possible for th GC to remain clean even if we access these > attributes, later even by using like: > > my value: get in myObject first ['attribute]
When the system Load this expression in the console or in a script, it adds 'attribute at the GC, so you do not reach your goal. Here it is the right version: myvalue: get in myObject first to-block "attribute" or you could do, to mask myvalue too: code: bind to-block { use [myvalue][ myvalue: get in myObject 'attribute print myvalue ] } 'system do code Bind doesn't add any word to the GC. So 'myvalue and 'attribute in this case are not added to the GC. It is possible to write functions which do not change GC, like: use-mask: func [vars [string!] code [string!]] [ do use to-block vars bind to-block code 'system ] use-mask "my" "my: 3 print my" func-mask: func [spec [string!] body [string!]] [ func to-block spec bind to-block body 'system ] x: func-mask "my" "print my" x 3 I've uploaded some example code to my rebsite (Romano).
> ciao! > > -Maxim
ciao, ciao Romano