It is customary to use the following idiom to partially evaluate something inside a held expression:
f[x_] := 2 x
Block[{f}, Hold[f[1 + 1]] /. x_f :> With[{r = x}, r /; True]]
Out[]= Hold[f[2]]
This works also with built-in symbols, like
Block[{Abs}, Hold[Abs[1 + 1]] /. x_Abs :> With[{r = x}, r /; True]]
Out[]= Hold[Abs[2]]
However, I cannot understand the behaviour of the following
Block[{Plus}, Hold[1 + 2*2] /. x_Plus :> With[{r = x}, r /; True]]
which returns Hold[5]
instead of Hold[1+4]
. Can someone explain why?
Times
has the same issue, so I suspect they're wired into the parser at a deep lvl in the name of efficiency. $\endgroup$