Re: Readability confuses mathematica?
- To: mathgroup at smc.vnet.net
- Subject: [mg44551] Re: Readability confuses mathematica?
- From: Tom Burton <tburton at brahea.com>
- Date: Fri, 14 Nov 2003 01:58:42 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Hello, Here is a simple workaround for the specific problem you mention below. Do this before you assign any subscripted symbols that you need to keep: ClearAll[Subscript] SetAttributes[Subscript, HoldFirst] Then in your example "x" will be unevaluated in the assignment of Subscript[x,0], so the two can be assigned independently. I do this all the time. Also with OverHat and decorations of all sorts. Be aware that your values are assigned not to x but to the global symbol Subscript. You can sometimes avoid this with, e.g., x/: Subscript[x,0] = blah but you cannot do x/: f[Subscript[x,0], Subcript[x,1]] = blah because x is "too deep" the left-hand expression. Rather than cope with this inconsistency, I would rather deal with assignments to Subscript, which are more tedious to clear. (Read about it in on-line help: "Further examples" under Clear.) Hint: This won't work right: With[{x=3},Subscript[x,0]=4] Because the symbol x disappears during preprocessing in favor of "3", you get Subscript[3,0]=4, regardless of the HoldFirst attribute of Subscript. Consider Block instead of With. Hint: Module creates new names of local symbols at every execution of the procedure. A consequence is that, if you form subscripts from local symbols, assignments to Global`Subscript pile up as you re-execute the procedure. Consider Block rather than Module for procedures. I too have had trouble with the Notations package when used within my packages. Specifically, initialized cells involving Notations symbols could spontaneously change and stop working. I could not abide this and so gave up the Notation package sometime during Version 4. Perhaps it's better now. But I get along OK with bandaids above, so... Tom Burton On 11/12/03 3:30 AM, in article botcm2$ci7$1 at smc.vnet.net, "patrick_m_lahey" <patrick.m.lahey at aero.org> wrote: > In[1]:= D[x-x0,x] > > except that x0 is really x ctrl-- 0 (x subscript 0). Normally that > would be a completely independent variable from x but not according to > mathematica!