Re: Subscript[x,
- To: mathgroup at smc.vnet.net
- Subject: [mg104073] Re: Subscript[x,
- From: danl at wolfram.com
- Date: Sun, 18 Oct 2009 05:22:28 -0400 (EDT)
- References: <hb9jt6$ke$1@smc.vnet.net> <200910171103.HAA13239@smc.vnet.net>
> "Nasser M. Abbasi" <nma at 12000.org> wrote: > >> 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 related vein, I find the following long-standing behaviour to be > irksome and illogical: > > > In[1]:= Subscript[x, 1] = 3 > > In[2]:= Clear[Subscript[x, 1]] > > Clear::ssym: Subscript[x, 1] is not a symbol or a string. >> > > To clear the subscript, you have to use Unset, which produces beeps if > the Subscript[x,1] has not been assigned a value. All so messy. > > Why not just make Clear do what it is meant to do, or at least, make it > do what people reasonably expect it will do? > > Cheers > > Colin > I have also run afoul of this, and found it to be a minor irretant. But I don't think the "obvious" thing would be the right thing, and I am not convinced it would be feasible within the current design of the language. Unset is meant to undo Set/SetDelayed, and handles this as it ought. Clear is meant to remove DownValues and the like. These are attached to symbols, not toexpressions. I think this is quite appropriate, as it supports a substantial portion of Mathematica programming. So invoking Clear on a non-symbol is not going to manage what you have in mind. Should it be extended to perform Unset on non-symbol expressions? I would surmise that might have some unexpected side effects (this is a quick guess and I have not thought it through in detail). It would certainly be a bit weird to overload Clear to do what it normally does with symbols, and something else with non-symbol expressions. Daniel Lichtblau Wolfram Research
- References:
- Re: Subscript[x,1] value do not get cleared using Clear["Global`*"] but get removed using Remove["Global`*]
- From: Colin Rose <colin@tri.org.au>
- Re: Subscript[x,1] value do not get cleared using Clear["Global`*"] but get removed using Remove["Global`*]