In order to answer this question, I just stumbled into the world of UpValues. Though I managed to find a solution for the problem, I'm confused by my own code now 囧, consider the following line of code:

baseForm /: MakeBoxes[baseForm[a_, b_], fmt_] := ToBoxes@BaseForm[a, b]

It makes baseForm display like BaseForm, by setting upvalue to… where?

"That goes without saying, it's in baseForm!" Huh?:

UpValues /@ {baseForm, TagSetDelayed, MakeBoxes, a, b, 
             Pattern, fmt, SetDelayed, ToBoxes, BaseForm}
(* {{}, {}, {}, {}, {}, {}, {}, {}, {}, {}} *)

The upvalue(?) can be found in the Information of baseForm, indeed:


enter image description here

But where is it stored in?


1 Answer 1


Assignments to MakeBoxes and Format get special treatment. The definitions are stored as (under-documented) FormatValues:

FormatValues[baseForm] // InputForm

{HoldPattern[MakeBoxes[baseForm[a_, b_], fmt_]] :> ToBoxes[BaseForm[a, b]]}

Note that if we omit InputForm from the expression above, then the system will attempt to apply the formatting to baseForm within the definition itself and give a misleading result:


BaseForm::intpm: Positive machine-sized integer expected at position 2 in BaseForm[a_,b_]. >>

BaseForm::intpm: Positive machine-sized integer expected at position 2 in BaseForm[a,b]. >>

  • 1
    $\begingroup$ Wow, I didn't even know that FormatValues existed! "Under-documented" even feels a bit euphemistic though... $\endgroup$
    – sebhofer
    Nov 26, 2015 at 15:51
  • $\begingroup$ Gee, I stumbled over this problem now for the second time. Good to have StackExchange. I wish I could upvote for a second time. Many thanks to WReach! $\endgroup$ Dec 6, 2017 at 9:30

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.