So, in an attempt to help out Fabian with his question, I did what I often do, and created a new symbol in the Pillsy` package that I could play with. Since it was in a package I control completely, I thought, "Hey, I can just call it Times!". I was really surprised when this happened:

In[3]:= Pillsy`Times[a, b, c]
Out[3]= a * b * c

It looks like Mathematica uses just the symbol name in determining whether to replace something with infix syntax, without paying attention to the context. However, I'm fairly sure I've never seen it happen before and I don't recall coming across it in the documentation. Evidently specifying InputForm shows you the whole thing:

In[4]:= Pillsy`Times[a, b, c] // InputForm
Out[4]= Pillsy`Times[a, b, c]

This is in contrast to the InputForm for System`Times.

Is this an intentional feature (it's hard to imagine otherwise), and if so, how does it interact with things like MakeBoxes, MakeExpression and Format?

Also, how do you avoid being burned by it? I'm a little alarmed that my assumption that a * b * c is the same thing as System`Times[a, b, c] is unfounded, even in the absence of changes to $Post and the like.


2 Answers 2


It seems like the StandardForm (default for output) of Times in any context (or Plus, etc) is with the * and + symbols.

But your assumption isn't wrong I think, the symbols * and + are mapped to System Times and System Plus. Try

PrependTo[$ContextPath, "blo`"];
blo`Times[a_, b_] := 8;

FullForm@MakeExpression[RowBox[{"a", "*", "b"}], StandardForm]

I think that this goes against Mathematica policy that "StandardForm generates output that gives a unique and unambiguous representation of Mathematica expressions, suitable for use as input"


The problem seems to be with ToBoxes:

==> {{"a b", "foo`Times[a, b]"}, {\(a\ b\), \(a * b\)}}

Note that Times and foo`Times are still different in that for Times, no * is generated.

When typing to the kernel directly, OutputForm is used, and foo`Times[a,b] gets printed:

In[1]:= {Times[a,b], foo`Times[a,b]}

Out[1]= {a b, foo`Times[a, b]}
  • $\begingroup$ If you try it with Plus the + is generated for both $\endgroup$
    – Rojo
    Commented May 3, 2012 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.