It seems to be a fairly common convention to write certain 'meta' functions in postfix form like
f[x] // Simplify
to keep the the mathematical content at the front separate from the various directives. However converting expressions to StandardForm
or InputForm
converts everything to prefix. Is there a way to get StandardForm
to use this convention or alternatively is there a form like StandardForm
, but that uses this convention. I find myself often switching betweenStandardForm
and InputForm
while editing since I prefer to just edit textually using InputForm
and then convert to StandardForm
for display, but this makes it impossible to use the above convention.
Reading the documentation I came across Format
which seems one possible way to do this, but the following does not work:
Format[Simplify[x_], StandardForm] := Postfix[Simplify[x_]]
Apparently Simplify
gets evaluated out before this rule is set up. I tried using Hold
and Unevaluated
to fix this without luck. This approach would also have the downside of having to define this rule for every function separately and I also do not yet know how I would set up such rules as a default for all my notebooks. So maybe there is a better way.
Postfix
is a typesetting function and not the same as//
in functionality $\endgroup$SetDelayed::write: "Tag Simplify in MakeBoxes[Simplify[expr_],StandardForm] is Protected"
in my notebook. $\endgroup$Unprotect
but better not. $\endgroup$Simplify
to always appear in postfix position. I do not care that much if the actual expression gets rearranged or if it is just rendered that way, which is what I understandFormat
rules do. $\endgroup$InputForm
gets formatted. FurthermoreInputForm
works on expressions rather than boxes, so that making a solution based on whether you typed postfix vs prefix seems to be impossible, as the information of whether you typed prefix or postfix is lost when the boxes get converted byMakeExpression
. $\endgroup$