Sometimes I'd like to make a function, which would take an argument "by reference" instead of usual "by value". This is semantically similar to what e.g.
AppendTo does: changes the variable passed to it. But when I try to do this straightforwardly, I get:
myFunc[x_] := (Clear[x]; x = 1) test = 0; (* dirty the variable *) myFunc[test];
Clear::ssym: 0 is not a symbol or a string. >>
Set::setraw: Cannot assign to raw object 0. >>
x is treated as "the value of
x" inside the function. How do I change
myFunc to treat
x as "the symbol passed as
x", so that it works like intended?