Background: there are many, many questions here about the infamous ::setraw error. More often, than not, they have to do with repeated assignments to symbols.
Here's the code:
ls = {a, b, c};
Evaluate[ls] = {1, 2, 3};
This command will work only once. It got me thinking, how, once a, b, and c already have OwnValues, would one go about reassigning them, by using only the symbol ls and not referencing a, b, or c directly?
What about injecting them into Block, Module and related?
Of course, all sorts of combinations of OwnValues, Hold, etc, that came to my mind, at one point or another need an Evaluate or similar at some point, but Evaluate immediately drills down to {1, 2, 3}.
I post one approach that seems to work as a self-answer, but it feels rather hackish. I'm pretty sure, there are better ways to go about this.
Hold[ls]/.OwnValues[ls]/.Hold[res_]:>(res = {1,2,3}). More generally, one can doUnevaluated[code]/.OwnValues[sym], in this case it will beUnevaluated[ls = {1,2,3}] /. OwnValues[ls]. This form will be easy to generalize to several symbols in need of partial evaluation. – Leonid Shifrin Mar 02 '16 at 15:47Block[Join[list1,list2], code], but I see now, that this would drastically shift the goalposts. Maybe, when I encounter this use case again, I'll ask a new question. The injector pattern is much simpler than I thought, though, thanks. – LLlAMnYP Mar 02 '16 at 16:10Blockthing can also be done relatively easily. If you pass them directly, thin something like this:ClearAll[block]; SetAttributes[block, HoldAll];block[symlists : {__Symbol} ..., code_] := Join @@ Apply[Hold, Unevaluated[{symlists}], {1}] /. Hold[syms___] :> Block[{syms}, code];. Example:{x, y, z, t} = {1, 1, 1, 1}; block[{x, y}, {z, t}, Print[x, y, z, t]]. If you store them in variables, add an extra step like the one I described above. – Leonid Shifrin Mar 02 '16 at 16:32