MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: MakeBoxes vs Format

  • To: mathgroup at smc.vnet.net
  • Subject: [mg60163] Re: MakeBoxes vs Format
  • From: Cca <cca at gregosetroianos.mat.br>
  • Date: Mon, 5 Sep 2005 02:27:54 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Ted Ersek asks:

>>When and why should we use (Format definitions) vs (MakeBoxes >>definition).

>>Are there any other pros and cons between use of MakeBoxes and >>Format?


Remember that MakeBoxes appeared in version 3.0, while Format exists since version 1.0. 
So far, ALL my work with box expressions has been done with MakeBoxes, but  as far as I have seen
a declaration like

Format[expr1]:=expr2

is,for all purposes, equivalent to

h/: MakeBoxes[expr1,formattype_] :=
  MakeBoxes[#,formattype]&@@{expr2}

where h is the Head  of expr1.

If you use

MakeBoxes[expr1,formattype_] :=
  MakeBoxes[#,formattype]&@@{expr2}

the rule will be stored in FormatValues[MakeBoxes] (FormatValues[h] will be empty).

Try this with the examples from the manual. For example:


Format[xrep[n_]]:=StringJoin[Table["x",{n}]]

Attributes[ParsedForm]=HoldAll;
Format[ParsedForm[expr_]]:=HoldForm[FullForm[expr]]

Format[bin[x_,y_]]:=MatrixForm[{{x},{y}}]



Carlos César de Araújo
Gregos & Troianos Educacional
www.gregosetroianos.mat.br
Belo Horizonte, MG, Brasil
(31) 3283-1122


  • Prev by Date: Re: PC Requirements for Mathematica
  • Next by Date: Re: Labeling points in ListPlot
  • Previous by thread: MakeBoxes vs Format
  • Next by thread: Re: Re: my wish list for Mathematica next major version