a: "qwerty" a: "qwerty" a: "qwerty"
Againg three string in memory?
set-word!s evaluate differently if the word needs to be added to the context from when the word has already been added to the context.
Typing out a word(without pressing enter) creates 4 instances. Of those, 2 instances are 2-byte word encodings, one is history of whole console.
Pressing enter gives me an obvious error about the word having no value, and 8 more instances are created (which includes the error message).
Note that it's all done in the console on Win10.
So, depending on how things are done, it may take up different memory in ways one wouldn't have thought!
Also, being alpha software, there's still space for much improvement here.
@9214 @greggirwin read your last messages and head explodes twice... Let
a: "1234567890"and after
a: "". This mean what somewhere in memory exist string "1234567890" and word
abound to it. After this we create new string "" and bound
ato it. Now no one pointer look on "1234567890" - and this string must be garbage collected?
The answer has still not solved some points like this. Hope @dockimbel will help clarify.
I'm not sure what is missing from above explanations, but to answer your question, a series which is no longer referenced anywhere will be garbage -collected. If you put that string in a function body block, it is referenced.
how can you, oh mighty Redbol gurus, live on such mental heights without your head exploding?
With Redbol, it's most of time simpler than you think. I'm trying to write down some general explanations of the core concept, for the Red documentation and eventually a blog article.
series!could be modified in-place, am I right that with
ref!datatype such self-modification will be doable with everything?
@in Firefox, I have to copy it)
not sure what I meant either :D
>> f: func [x][y: 0 y: y + x] == func [x][y: 0 y: y + x] >> f 5 == 5 >> body-of :f == [y: 0 y: y + x]
>> f: func [x][y:  y/1: y/1 + x] == func [x][y:  y/1: y/1 + x] >> f 5 == 5 >> body-of :f == [y:  y/1: y/1 + x]
what if I want
y in the first example to be modified as in the second example, only without explicit block wrapping?
ref!is something like a pointer to series position
>> 220.127.116.11.18.104.22.168.22.214.171.124 == 126.96.36.199.188.8.131.52.184.108.40.206 >> 220.127.116.11.18.104.22.168.22.214.171.124.13 *** Syntax Error: invalid tuple! at "126.96.36.199.188.8.131.52.184.108.40.206.13" *** Where: do *** Stack: load
handle!datatype for that?
ref! name was discussed quite heavily at one point, on atlme too, but is not finalized. We also have
tuple! with a different meaning than in other languages. What we need to do is ask: "What is the main purpose of this datatype? What does it represent?" People new to Red have a lot of concepts to learn, and old habits and ideas to un-learn.
I'm short on time, but will try to write up thoughts in the future. But
ref! values aren't just for human handles in chat (e.g. @pekr). They could be used to refer to locations in code, as in a cross-reference, a specific message in a chat, a point in time, etc. That is, it refers to something. And since Red has no concept of a pointer, though R/S does, there shouldn't be much confusion after initial exposure.
set-word!is - it's just this type of marker.
set-word!points to location in source code, while variables usually point to location in memory. But there's no variables in Redbol. In a vague sense, script's body is it's own memory. Entire script is just one big chunk of self-modifiable state, which can be trivially serialized, saved and restored.