# To TagSet or not to TagSet when using MakeBoxes

What is the difference between the following two:

(*1: UpSet definition*)
myfuncF /: MakeBoxes[myfuncF[a_, b_], TraditionalForm] :=
RowBox[{"f(", Sequence @@ Riffle[Map[ToBoxes, {a, b}], ","], ")"}]


and

(*2: MakeBoxes definition*)
RowBox[{"f(", Sequence @@ Riffle[Map[ToBoxes, {a, b}], ","], ")"}]


With myfuncF[a,b] // TraditionalForm I get for both the following output.

f(a, b)

Is one preferable over the other?

• One observation here which I find interesting is that MakeBoxes is HoldAllComplete. This should mean that it doesn't perform any UpValue search. Yet, UpValue-based definitions do work with it. There must be something rather interesting going on there, but I never had the energy to investigate deeper. – Leonid Shifrin Oct 19 '14 at 20:29
• @LeonidShifrin I remember from playing around some time ago that these don't set upvalues or downvalues but format values. If I remember correctly these are tried in the logical order but only after downvalues – Rojo Oct 20 '14 at 3:01
• @QuantumDot if this is the case I would use the UpSet definition because once you clear myfuncF the definition is cleared too, but it doesn't seem like a big deal anyway – Rojo Oct 20 '14 at 3:03
• @Rojo It turns out I can format things like $f^2(x,y)$ by using MakeBoxes[Power[myfuncF[a_, b_], n_], TraditionalForm] := RowBox[{SuperscriptBox["f", ToBoxes[n]], "(", Sequence @@ Riffle[Map[ToBoxes, {a, b}], ","], ")"}], which I cannot do using UpSet (since myfuncF would be too deep). – QuantumDot Oct 24 '14 at 11:32
• @LeonidShifrin see my comment above to Rojo – QuantumDot Oct 24 '14 at 11:33

Generally speaking, that TagSetDelayed form is preferable, as the rule is attached to the myfuncF rather than to MakeBoxes. This means:
1. Clear[f] will remove the FormatValues.
As pointed out in some of the comments, this may not work if you have a specific rule for when myfuncF is embedded inside another expression. In that case you'll need to either attach the rule to that other head, or live with it being attached to MakeBoxes.
Note that whether you use SetDelayed or TagSetDelayed, neither an up value or a down value is created, but rather a format value.