If you need help, try to find the answer through the following path: `Help` in the console ⇒ [Red by Example](https://www.red-by-example.org/) ⇒ [Official Red Docs](https://github.com/red/docs/blob/master/en/SUMMARY.adoc) ⇒ [Rebol Core Manual](http://www.rebol.com/docs/core23/rebolcore.html ⇒ [Red Wiki](https://github.com/red/red/wiki ⇒ Net search "redlang + your-question" ⇒ Ask us, we are here to help!
"Kasa " [
text form 123
]
view compose/deep [
;your code
]
copy
or copy/deep
, for "why" - series!
values are passed as pointers to some memory location, then you say something like word: []
, it means "allocate some space for series, initiate it with some content (no content in this case) and make word point to that storage space" . So, in fact,word
from that moment is always bound to static memory address, while content of that address could be changed and extended freely.
>> foo: func [x][s: [no spoon] probe append s x poke body-of :foo 2 [no spoon]]
== func [x][s: [no spoon] probe append s x poke body-of :foo 2 [no spoon]]
>> foo 'whatsoever
[no spoon whatsoever]
== [no spoon]
>> body-of :foo
== [s: [no spoon] probe append s x poke body-of :foo 2 [no spoon]]
self
could be supported in specs?
>> foo: func [x][s: "before" probe append s x s: "after" probe s]
== func [x][s: "before" probe append s x s: "after" probe s]
>> foo "!!!"
"before!!!"
"after"
== "after"
>> body-of :foo
== [s: "before!!!" probe append s x s: "after" probe s]
Step by step:s:
means next time when you see s
, evaluate it to the result of an expression that follows me, whatever it might be;"before"
is just a string to which s
word is bound now, as implied by s:
syntax;append
is word that is bounded to a function, that function receives two arguments that follow append
word;s
, evaluates to the thing that follows s:
, namely "before"
string, or, more specifically second element of foo
's body;x
, evaluates to whatever we've passed to foo
;append
does is just this: append some value to second element of foo's body;s:
, just like the first one, simply states next time when you see s
, evaluate it to the result of an expression that follows me, whatever it might be;"after"
is what follows s:
, it's the 8th element of foo's body, all subsequent s
words will be evaluated to it;probe
is a word that is bounded to function that blah-blah-blah;s
is evaluated to the 8th element of foo's body, and it is what it is, just "after"
.@GiuseppeChillemi, see https://github.com/red/red/wiki/Why-do-I-have-to-copy-series-values%3F
Or maybe this will help:
print-it: func [] [
""
insert first body-of :print-it "ha"
print first body-of :print-it
""
]
>> print-it
ha
== ""
>> print-it
haha
== ""
>> print-it
hahaha
== ""