For the definitions,
t = 1;
f[x_, y_] := t (x + y);
v[3] := {1, 1};
g[u_] := f[v[u][[1]], v[u][[2]]];
the following two expressions yield different results, despite the only difference being the name of the iterator.
Table[g[s], {s, 3, 3}]
Table[g[t], {t, 3, 3}]
I believe this is related to how Table
applies the value of its variables, as mentioned in https://mathematica.stackexchange.com/a/23533.
Are there other functions that behave similarly (albeit bizarrely)? Other than using a different variable name for the iterator, are there good ways to avoid this issue?
Table
is here just one example of where this goes wrong. And the title is just right here - this is a general issue with the scoping done wrong. I believe that we need this one as is - for future reference here on SE, since this issue pops up in this or that form very often. This question allows to address the problem in its minimal (and general) form. This is why I bothered with the answer and tried to make it as brief as possible. $\endgroup$