All symbols created by “ToExpression” are defined in Global
In[]:=
Remove["Global`*"]
In[]:=
a=b=999;​​xxx={"a=3","b=a+1"};​​ToExpression[#]&/@xxx​​Print[a," ",b]
Out[]=
{3,4}
3 4
In[]:=
Names["Global`*"]
Out[]=
{a,b,xxx}
Using Module. All symbols created by “ToExpression” are defined in Global! They are not internal in the Module.
In[]:=
Remove["Global`*"]
In[]:=
a=b=999;​​xxx={"a=3","b=a+1"};
In[]:=
test[x0_]:=Module[{a=111,b=222,x=x0},ToExpression[#]&/@x;Print[a," ",b," ",x]]
In[]:=
test[xxx]​​Print[a," ",b]
111 222 {a=3,b=a+1}
3 4
In[]:=
Names["Global`*"]
Out[]=
{a,a$,b,b$,test,x,x0,xxx,x$}