Consider the following toy example:
prepareBoxes[foo[expr_]] := message["The argument was " <> ToString@expr]; MakeBoxes[foo[expr_], StandardForm] := ToBoxes@prepareBoxes@foo[expr]
foo then gives the expected result:
foo (* message["The argument was 2"] *)
But if I want to review the definition of
Information I get the following:
Notice how the custom
MakeBoxes gets evaluated on the LHS of the definition of
This is weird enough, and arguably not the wanted result, but it may still be fine.
The problem arises if the definition of
prepareBoxes is slightly different:
prepareBoxes[foo[expr_Integer]] := message["The argument was " <> ToString@expr]; MakeBoxes[foo[expr_], StandardForm] := ToBoxes@prepareBoxes@foo[expr]
where I just changed the definition of
prepareBoxes to only trigger when the input is an
prepareBoxes with this definition we get an infinite recursion, for the same reason we got the wrong evaluation in the case above:
Is this behaviour considerable as a feature? It can be quite annoying in many occasions.
Is it avoidable? If so, how?