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

[REBOL] Re: Rebol pickling recipes ?

From: g:santilli:tiscalinet:it at: 6-Oct-2002 12:05

Hi Laurent, On Saturday, October 5, 2002, 10:13:48 PM, you wrote: LG> Each answer seem to bring up new questions again ;) That's good, isn't it? :-) LG> What exactly do you mean by "loading" words without using 'load ? This is somewhat a long story; I'll try to make it short.
>> find first system/words 'a-word
== [a-word]
>> find first system/words 'another-word
== [another-word]
>> find first system/words 'a-word-never-defined-before
== [a-word-never-defined-before] You see, it looks like REBOL's SYSTEM/WORDS already contains all possible words. But actually, it doesn't. They just get added by LOAD, at the time the text you write at the console is LOADed into REBOL, just before it is evaluated. So:
>> load "a-different-word"
== a-different-word
>> 'a-different-word2
== a-different-word2
>> find first system/words 'a-different-word
== [a-different-word a-different-word2] LOAD adds 'A-DIFFERENT-WORD to SYSTEM/WORDS (you see, it gets added before 'A-DIFFERENT-WORD2). However, LOAD is not the only function that can "create" a word.
>> to-block "a block of words"
== [a block of words] It doesn't add the words to SYSTEM/WORDS:
>> find first system/words first to-block "different-again"
== none So no track remains about the fact that that word has been created. One could think of creating a context made of words that are not added to SYSTEM/WORDS; this means that if you don't have access to that context in some way (i.e. if it isn't an object, or the context of a function, etc.) it is not possible to say which words are part of that context. As a result, you cannot reproduce that context by simply looking at the SYSTEM. BTW, I just found out this curious behavior:
>> find first system/words to-word "never-defined-this"
== none
>> find first system/words to-word "never-defined-this"
== [never-defined-this] which shows that using TO-WORD the word gets added AFTER the evaluation of that expression. I cannot give an explanation of this; it might be some kind of side effect of the current implementation (this is REBOL/View 3-Aug-2002); Ladislav, Romano, do you have any ideas? LG> I guess that by "partially" you mean "only for the context that your script(s) LG> have knowledge of" ? Yup, something like that. :) LG> Would that mean that, for example, one would have to store all code and data LG> within a single object to make sure everything he needs is correctly restored LG> (puting aside the need to handle circular references properly) ? That could help. However, as long as you are in control of what it is needed to restore your system, you can easily do it. (I.e. if you know what state your script needs, you just save it and then restore it.) Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: