Lets say I define a few words:
Word1: 5
Word2: "blahdiddyblah"
Is there some part or block of the system that stores which words are in use?
Tried something like this but it failed:
S1: to-block copy system/contexts/user
D: 3
S2: to-block copy system/contexts/user
Difference s1 s2
According to @johnk suggestion, I tried:
>> snapshot-of-words: words-of system/contexts/user
== [system snapshot-of-words words-of contexts user]
>> x: 1
== 1
>> difference snapshot-of-words words-of system/contexts/user
== [x difference]
>> difference snapshot-of-words words-of system/contexts/user
== [x difference]
>> 5 + 9
== 14
>> form ["hellow" "there" ]
== "hellow there"
>> difference snapshot-of-words words-of system/contexts/user
== [x difference + form]
What does this mean? native functions are bound into the user context after use? Is there a way to isolate these from those a user might bind?
When you use words in a script - every command line you enter interactively is a different script - those words are added to system/contexts/user
, the user context. Simply having the words in the script at all gets them added to the user context, that is all the "use" that is needed. If any of these new words already exist in lib
, the runtime library, then the user context words get their initial values assigned from the values that those words have in the runtime library at that moment.
In your example code, when you use the word form
in your script it is added to the user context. Then form
is assigned the value that lib/form
is assigned at the time. From then on, form
is a user word - the system word is lib/form
.
The only time that the values of words propagate from lib
to the user context is when that word is first added to the user context and given its initial value. After that, if you want any changes in the lib
version of that word to make it into the user context version of that word, you have to assign it yourself. If they have the same value going forward then it is just because you haven't assigned a new value to either the user or system words.
All words in the user context are words that the user made, even the ones that were initialized from lib
. The user made those words when they put them in user scripts. That is the whole point to the user context. So, if you use print
in your script, that is a user word, no different from any other user words.
You might want to look here for more details: How are words bound within a Rebol module? And here too: What is the summary of the differences in binding behaviour between Rebol 2 and 3?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With