Suppose I want to display some expression, say foo[p1_,p2_], as a point in a circle.
I can achieve this using MakeBoxes, like in the following:
ClearAll[foo];
foo /: MakeBoxes[foo[p1_, p2_], fmt_] :=
GraphicsBox[{CircleBox[{0, 0}], PointSize@0.08, PointBox[{p1, p2}]},
ImageSize -> 70]
which produces the desired result:
However, a problem arises when I use ??foo:
As you can see, Mathematica is also issuing MakeBoxes on the foo[p1_,p2_] that should appear in the informations.
Infact, the problem can be traced back to the fact that also the expression
foo[a_,b_]
triggers the MakeBoxes evaluation.
How can this problem be avoided?
PS: apologies for the not-much-informative title, please change it if you find a better way to describe the question.





MakeBoxes[foo[p1_?NumberQ, p2_?NumberQ], fmt_]? – J. M.'s missing motivation Feb 27 '16 at 01:35