WOLFRAM LANGUAGE TUTORIAL
Low‐Level Input and Output Rules
|MakeBoxes[expr,form]||construct boxes to represent expr in the specified form|
|MakeExpression[boxes,form]||construct an expression corresponding to boxes|
Low‐level functions for converting between expressions and boxes.
generates boxes without evaluating its input.
Built into the Wolfram Language are a large number of rules for generating output and interpreting input. Particularly in StandardForm, these rules are carefully set up to be consistent, and to allow input and output to be used interchangeably.
It is fairly rare that you will need to modify these rules. The main reason is that the Wolfram Language already has built‐in rules for the input and output of many operators to which it does not itself assign specific meanings.
Thus, if you want to add, for example, a generalized form of addition, you can usually just use an operator like for which the Wolfram Language already has built‐in input and output rules.
This outputs using the
The Wolfram Language understands
In dealing with output, you can make definitions for Format[expr] to change the way that a particular expression will be formatted. You should realize, however, that as soon as you do this, there is no guarantee that the output form of your expression will be interpreted correctly if it is given as Wolfram Language input.
If you want to, the Wolfram Language allows you to redefine the basic rules that it uses for the input and output of all expressions. You can do this by making definitions for MakeBoxes and MakeExpression. You should realize, however, that unless you make such definitions with great care, you are likely to end up with inconsistent results.
is now output using a subscripted
The Wolfram Language cannot, however, interpret this as input.
This tells the Wolfram Language to interpret a subscripted
as a specific piece of FullForm
Now the subscripted
is interpreted as a
When you give definitions for MakeBoxes, you can think of this as essentially a lower‐level version of giving definitions for Format. An important difference is that MakeBoxes does not evaluate its argument, so you can define rules for formatting expressions without being concerned about how these expressions would evaluate.
In addition, while Format is automatically called again on any results obtained by applying it, the same is not true of MakeBoxes. This means that in giving definitions for MakeBoxes you explicitly have to call MakeBoxes again on any subexpressions that still need to be formatted.
|■ Break input into tokens.|
|■ Strip spacing characters.|
|■ Construct boxes using built‐in operator precedences.|
|■ Strip StyleBox and other boxes not intended for interpretation.|
|■ Apply rules defined for MakeExpression.|
Operations done on Wolfram Language input.