Skip to main content

InterpretationBox

Wolfram Kernel
Execution environment

Make a formatting structure whose interpretation is not based on its appearance

InterpretationBox[display_, expr_]

where display will be shown in the output cell, instead of expr, keeping expr for the evaluation.

info

display can be any Wolfram Expression wrapped in MakeBoxes

danger

display must be Boxes, if you want to use regular WL expressions, consider Interpretation

tip

Please see BoxBox and ViewBox for an advanced expression decorations

tip

See more at Decorating symbols

Applications

One of the examples is to make some definitions shorter by setting UpValues to MakeBoxes, since the last one is recursively applied to everything in the output cell

AVeryLongFunction /: MakeBoxes[AVeryLongFunction, StandardForm] := InterpretationBox[MakeBoxes[Ashort, StandardForm], AVeryLongFunction]

Now we can check the result by

AVeryLongFunction

if one define also this

AVeryLongFunction[expr__] := SpecialList[expr]

You can use it with the created alias Ashort

An expression will not be revealed

Dev notes

This is a wrapper for ViewBox with a read-only EditorView inside.