Red tries to reuse series and objects in memory as much as possible, for performance reasons. This means that using variables to point to the same series is often a bad idea and is the cause of hard-to-find bugs in your code. We have already told you in the Assigning and copying section in Chapter 3, Using Words, Values, and Types, that using copy is the safest way to ensure that your variables point to different memory locations. That way, changes to one variable don't affect the other.
To appreciate this fact, examine and try to predict the output of the following code:
;-- see Chapter05/copying.red:
not-expected: [
var1: ""
append var1 "*"
print var1
]
loop 3 [do not-expected]
The do word executes the not-expected code block and append joins the var1 string with a *.
You probably expected three * lines to be printed out. But...