please explain why ToExpression[SubscriptBox["x","1"],StandardForm] ...
- To: mathgroup at smc.vnet.net
- Subject: [mg71818] please explain why ToExpression[SubscriptBox["x","1"],StandardForm] ...
- From: "Chris Chiasson" <chris at chiasson.name>
- Date: Thu, 30 Nov 2006 06:05:12 -0500 (EST)
fails when the definition
MakeExpression[SubscriptBox["x","1"],___]=dog;
is active.
I think it is related to the output of
BoxForm`TopLevelMakeExpression[StripBoxes[SubscriptBox["x","1"]],StandardForm]
being
ErrorBox[dog].
If you can answer that, then I may be able to make my solution to
"[mg71653] Using subscripts in function-parameter names" work... here
is what I have so far:
Unprotect[SubscriptBox];
With[{usc=FromCharacterCode[63316]},
subscriptAsSymbol[symb_Symbol]:=
With[{symbStr=ToString@symb},
SubscriptBox/:
MakeExpression[SubscriptBox[symbStr,scriptStrs__String],format_]:=
MakeExpression[SubscriptBox[symbStr,scriptStrs],format]=
With[{symbWithSub=
ToExpression[
ToString@
BoxForm`Intercalate[SequenceForm[symbStr,scriptStrs],
usc],format]},
MakeBoxes[symbWithSub,_]=SubscriptBox[symbStr,scriptStrs];
symbWithSub]]];
subscriptAsSymbol@x;
ToExpression[SubscriptBox["x","1"],StandardForm]
--
http://chris.chiasson.name/