Consider the following example:
In[1]:= f[x_]:=x+1;g[x_]:=f[2x]
In[2]:= TracePrint[g[1]]
g[1]
g
1
f[2 1]
f
2 1
Times
2
1
2
f[2]
2 + 1
Plus
2
1
3
Out[2]= 3
So far, so good. However I'd now like to instruct TracePrint to treat evaluation of f as atomic, that is not to print the intermediate steps of evaluating f[2], so that the next line after f[2] would be 3 (but without excluding any other lines). My first idea was to just make f read protected:
In[3]:= SetAttributes[f,ReadProtected]
In[4]:= TracePrint[g[1]]
g[1]
g
1
f[2 1]
f
2 1
Times
2
1
2
f[2]
2 + 1
Plus
2
1
3
Out[4]= 3
As you can see, the inner working of f is still traced. However the attribute is otherwise honoured:
In[5]:= ?f
Global`f
Attributes[f] = {ReadProtected}
Another thing which does not work is
TracePrint[g[1],Except[_f]]
which again gives the complete trace.
So how do I instruct TracePrint to treat the function f as atomic?
TracePrinthelp page! – celtschk Apr 17 '12 at 09:52Tracehas a whole list of options. The documentation ofTracePrintsays (among other things): "TracePrint does not support the TraceBackward option of Trace." which (rather vaguely, I agree) implies other options ofTraceshould work. See also this tracing overview – Sjoerd C. de Vries Apr 17 '12 at 10:51TraceInternala boolean flag (previously documented, but not anymore) which will allow tracing into the internal functions not normally traceable. – rcollyer Apr 24 '12 at 02:36