Re: Subscript[x,1] value do not get cleared using Clear["Global`*"]
- To: mathgroup at smc.vnet.net
- Subject: [mg104061] Re: Subscript[x,1] value do not get cleared using Clear["Global`*"]
- From: Szabolcs Horvát <szhorvat at gmail.com>
- Date: Sat, 17 Oct 2009 07:04:04 -0400 (EDT)
- References: <hb9jt6$ke$1@smc.vnet.net>
On 2009.10.16. 13:03, Nasser M. Abbasi wrote: > Hello, > Version 7 on XP Sp2 > > Before, I used to use Clear["Global`*] to clear all variable, until I just > found subscripted variable do not get cleared > > In[31]:= Remove["Global`*"] > > In[33]:= Subscript[a, 1] = 5 > > In[34]:= Subscript[a, 1] > Out[34]= 5 > > In[35]:= Clear["Global`*"] --> now clear it > > In[36]:= Subscript[a, 1] > Out[36]= 5 ----> did not clear > > In[37]:= Remove["Global`*"] > In[38]:= Subscript[a, 1] > > Out[38]= Subscript[a, 1] ---> ok, removed > > I find the above a bit strange. I first thought may be becuase I did not > "symbolize" a_1 using the notation package, but even after doing that, a_1 > would still not be cleared of its value: > > In[59]:= Remove["Global`*"] > In[60]:=<< "Notation`" > > In[61]:= Symbolize[ParsedBoxWrapper[\(a\_1\)]] > > In[62]:= Subscript[a, 1] = 5 > Out[62]= 5 > > In[63]:= Clear["Global`*"] --> now clear it > > In[64]:= Subscript[a, 1] > Out[64]= 5 ----> did not clear > > In[65]:= Remove["Global`*"] > > In[66]:= Subscript[a, 1] > Out[66]= Removed[a\[UnderBracket]Subscript\[UnderBracket]1] > > I thought the above should make it so that a_1 is now "one" symbol, and it > should have been cleared? > > So now, to make sure I am starting with clean computation, I either will do > Remove[...] or restart the kernel. > > Do you find this strange or is it just me? > I usually just restart the kernel. The reason why Clear["Global`*"] won't clear Subscript[a,1] definitions is that they're associated with the symbol Subscript (which is not in the Global` context), and not the symbol 'a'. The reason why Remove["Global`*"] appears to work is that it removes all occurrences of the symbol 'a', replacing it with Removed[a] where it can't be actually removed (like in the definitions associated with Subscript). Definition[Subscript] will reveal that the definition is still there, though altered.