The code setString[name_String, value_]:= Evaluate[Symbol[name]] = value
fails whenever Symbol[name]
has already been assigned a value.
I know of only one way to affect the symbol denoted by a string without triggering further evaluation, and that is the Clear
function. Said function takes as arguments both symbols and strings denoting symbols. From this
setString[name_String, value_]:= Module[{},
Clear[name];
Evaluate[Symbol[name]] = value]
seems like the only solution.
This works, but is this the "correct" solution for the problem? It would not be possible without exploiting the "quirk" of Clear
to take both symbols and symbol names. Are there any other solutions?
Evaluate[Symbol[name], _Symbol]
, for example. $\endgroup$step
function could easily be adapted for the job. It would just be nice for it to be built in. If I get back to my computer and no one else has answered with something better, I’ll take a stab at it... $\endgroup$