When a HoldComplete
expression reaches the frontend, there will still be evaluation happening within it, namely for all expressions that have FormatValues
.
For example
Format[myx, StandardForm] = "somethingelse";
HoldComplete@myx
displays as
HoldComplete[somethingelse]
If I choose another Form
for which I have not defined FormatValues
, the formatting is not applied:
OutputForm@HoldComplete@myx
HoldComplete[myx]
Interestingly, SparseArray[{}, {2, 2}]
displays differently from HoldComplete@SparseArray[{}, {2, 2}]
(which stays unchanged) and I have not been able to find the ...Form
that would format the SparseArray
while inside HoldComplete
. I have tried
Through[(Symbol /@ Names["System`*Form"])@
HoldComplete@SparseArray[{}, {2, 2}]]
They must be using an internal codepath for that.
I'm also a bit surprised that many Form
s besides StandardForm
display HoldComplete@myx
as HoldComplete[somethingelse]
, try
Through[(Symbol /@ Names["System`*Form"])@HoldComplete[myx]]
What's bitten me is also that Manipulate
inside HoldComplete
are evaluated:
HoldComplete[Manipulate[0, {x, Abort[]}]]
gives
$Aborted[]
(interestingly, StandardForm@HoldComplete[Manipulate[0, {x, Abort[]}]]
gives $Aborted
without the extra []
).
The workarounds seem to be to apply any of ToString
, FullForm
, OutputForm
, InputForm
...
On a final note: FormatValues
of Manipulate
shows a rule for MakeBoxes
-- I thought you are supposed to define output formats by modifying Format[x, form]
?!
Where can I learn more about output formatting and format time evaluations?
I found ref/Format, tutorial/DefiningOutputFormats and maybe tutorial/FormattedOutput. Anything else?
Aside I just noticed that all FormatValues
report rules for MakeBoxes
...