This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / Built-in Functions / Programming / Debugging  /
TraceOn

  • TraceOn is an option for Trace and related functions which specifies when tracing should be switched on.
  • With the setting TraceOn -> patt, Trace and related functions do not start tracing until they encounter expressions to evaluate which match the pattern patt. This pattern is also tested against tags associated with the evaluation.
  • TraceOff can be used within tracing switched on by TraceOn.
  • Once tracing has been switched off by TraceOff, however, TraceOn will not switch it on again.
  • During the execution of Trace, the settings for TraceOn and TraceOff can be modified by resetting the values of the global variables $TraceOn and $TraceOff.
  • See the Mathematica book: Section 2.5.10.
  • See also: TraceOff.

    Further Examples

    Here is a recursive definition of a factorial function.

    In[1]:=

    Here is a rule for a log function.

    In[2]:=

    This shows all steps in the evaluation.

    In[3]:=

    Out[3]=

    This shows only those steps that occur during the evaluation of fac.

    In[4]:=

    Out[4]=

    This shows only those steps that do not occur during the evaluation of fac.

    In[5]:=

    Out[5]=