Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the idea I am trying to elaborate and test in the "Character2D" branches.
In WMA, "formatting" is the result of "render" a
Box
expression, and box expressions are generated by evaluatingMakeBoxes[expr]
in a way that is different from the standard evaluation.In WMA, the "normal" evaluation of the expression
MakeBoxes[expr, form]
discards any user definition and always proceed as follows:expr
.For example:
Notice that evaluating
MakeBoxes[F[x], StandardForm]
does not returns the (down) valueRowBox[...]
(which is what happens in Mathics) but applies first the format rule. Then, MakeBoxes rules are applied over the result of formatting.Notice also that MakeBoxes rules are looked first in the FormValues of the head of the resulting expression, and then in the downvaloes of MakeBoxes.
Here we reset the StandardForm of F in terms of
Fs
, and set a "UpValue" for MakeBoxes[Fs]:Now, when the REPL wants to format
F[1]
, uses theOutputForm
But if we ask for the StandardForm
MakeBoxes looks in FormatValues[Fs] for a rule. Setting a DownValue for MakeBoxes does not have any effect, because the rules are first looked in the FormatValues of
Fs
.Here we see that UpSet[MakeBoxes[...], ....] stores the second argument as FormatValues instead of Upvalues: