Bug introduced in 8.0.4 or earlier and persisting through 12.0 or later
Check this example:
Attributes[Unevaluated]
(*{HoldAllComplete, Protected}*)
FullForm[Unevaluated[{{5 + 6}, {7 + 8}}]]
(*Unevaluated[List[List[Plus[5, 6]], List[Plus[7, 8]]]]*)
now:
TreeForm[Unevaluated[{{5 + 6}, {7 + 8}}]]
expr = Unevaluated[{{5 + 6}, {7 + 8}}]
(*{{11}, {15}}*)
Note here the result is like Unevaluated
is not applied at all.
It looks like (according to the documentation also) that Unevaluated
uses its Attributes ONLY once.
When compared with HoldComplete
, which has same Attributes
, the results are different and as expected.
in the case of HoldComplete
:
FullForm[HoldComplete[{{5 + 6}, {7 + 8}}]]
(*HoldComplete[List[List[Plus[5, 6]], List[Plus[7, 8]]]]*)
TreeForm[HoldComplete[{{5 + 6}, {7 + 8}}]]
It is clear that the TreeForm
does not represent the FullForm
when using Unevaluated
and works perfectly in the case of HoldComplete
.
How does that happen with Unevaluated
?
TreeForm[Unevaluated[4^5]]
evaluate the4^5
?" $\endgroup$Unevaluated
is underdocumented. But I do not see a bug here. Internals of function implementations are allowed to stripUnevaluated
and presumablyTreeForm
is doing just that. $\endgroup$Unevaluated
" - Isn't this called evaluation leak? $\endgroup$