It seems that we can change the context of symbols:
In[1]:= x = 1
Out[1]= 1
In[2]:= Context[x] = "foo`";
But then x
is still interpreted as foo`x
(and not Global`x
) even though foo`
is not in $ContextPath
.
In[3]:= x
Out[3]= 1
In[4]:= foo`x
Out[4]= 1
The behaviour is not consistent though. At other times I randomly get this when evaluating the same sequence of expressions in a new kernel:
In[1]:= x = 1
Out[1]= 1
In[2]:= Context[x] = "foo`";
In[3]:= x
Out[3]= x
In[4]:= foo`x
Out[4]= 1
I see this random, erratic behaviour in M9, 10 and 10.1. In M8, x
is not seen any more as soon as its context is changed, i.e. it behaves as one would expect.
Questions:
- Why the random behaviour?
- Is it documented or discussed anywhere that
Context
an be changed?