Maybe this type of visualization will help understand the evaluation order better. Things are printed in InputForm here, but please "think" FullForm when you look at expressions.
In[2]:= On[]
Plus[3^3,6*9]
Off[]
During evaluation of In[2]:= On::trace: On[] --> Null. >>
During evaluation of In[2]:= Power::trace: 3^3 --> 27. >>
During evaluation of In[2]:= Times::trace: 6 9 --> 54. >>
During evaluation of In[2]:= Plus::trace: 3^3+6 9 --> 27+54. >>
During evaluation of In[2]:= Plus::trace: 27+54 --> 81. >>
Out[3]= 81
In[5]:= p=Plus
Out[5]= Plus
In[6]:= On[]
p[3^3,6 9]
Off[]
During evaluation of In[6]:= On::trace: On[] --> Null. >>
During evaluation of In[6]:= p::trace: p --> Plus. >>
During evaluation of In[6]:= Power::trace: 3^3 --> 27. >>
During evaluation of In[6]:= Times::trace: 6 9 --> 54. >>
During evaluation of In[6]:= Plus::trace: p[3^3,6 9] --> 27+54. >>
During evaluation of In[6]:= Plus::trace: 27+54 --> 81. >>
Out[7]= 81
This shows the evaluation order clearly and precisely. In the second example,
- evaluate
p -> Plus
3^3 -> 27
6*9 -> 54
p[3^3,6 9] -> Plus[27, 54]
27+54 -> 81
TracePrint shows the same information, but perhaps it's not quite as clear:
In[9]:= TracePrint[p[3^3,6 9]]
During evaluation of In[9]:= p[3^3,6 9]
During evaluation of In[9]:= p
During evaluation of In[9]:= Plus
During evaluation of In[9]:= (3^3)
During evaluation of In[9]:= Power
During evaluation of In[9]:= 3
During evaluation of In[9]:= 3
During evaluation of In[9]:= 27
During evaluation of In[9]:= 6 9
During evaluation of In[9]:= Times
During evaluation of In[9]:= 6
During evaluation of In[9]:= 9
During evaluation of In[9]:= 54
During evaluation of In[9]:= 27+54
During evaluation of In[9]:= 81
Out[9]= 81
It also mentions subexpressions that evaluate to themselves (i.e. don't evaluate), e.g. Times -> Times or 6 -> 6.
The evaluation sequence is documented in detail here:
Plus[3^3, 6*9] // Trace– mfvonh Jun 24 '14 at 05:32Holdis that what is inside it does not get evaluated :) But once you release the hold it would be evaluated in the standard order as you describe. – mfvonh Jun 24 '14 at 05:39p = Plus; p[3^3, 6*9] // Trace. Notice how it evalutesp, then it evalutes what's inside, then it evaluates the whole expression including the head and the interior elements. That's how, for example, it knows not to evaluate the things insideHold. – mfvonh Jun 24 '14 at 06:07My question is why: Plus[2,3] //traceViewCompact Plus[2,b] //traceViewCompact turned out to be different steps evaluating? Namely 2->3->5->5(weird trivial evaluation) and 2,b,2+b
– Eric Jun 26 '14 at 15:54