Consider the following toy example:
prepareBoxes[foo[expr_]] :=
message["The argument was " <> ToString@expr];
MakeBoxes[foo[expr_], StandardForm] := ToBoxes@prepareBoxes@foo[expr]
Evaluating foo[2]
then gives the expected result:
foo[2]
(* message["The argument was 2"] *)
But if I want to review the definition of foo
with Information
I get the following:
Notice how the custom MakeBoxes
gets evaluated on the LHS of the definition of prepareBoxes
.
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 Integer
.
Evaluating Information
on 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?