TraceDialog

TraceDialog[expr]
initiates a dialog for every expression used in the evaluation of expr.

TraceDialog[expr, form]
initiates a dialog only for expressions which match form.

TraceDialog[expr, s]
initiates dialogs only for expressions whose evaluations use transformation rules associated with the symbol s.

Details and OptionsDetails and Options

  • The expression to be evaluated when a dialog is called is given as Out[$Line] of the dialog, wrapped in HoldForm. The expression can be seen by asking for when the dialog is first started.
  • Any value returned from the dialog is discarded.
  • TraceDialog[expr] returns the result of evaluating expr.

ExamplesExamplesopen allclose all

Basic Examples (1)Basic Examples (1)

Trace evaluation of an expression, entering a Dialog whenever addition is encountered:

In[1]:=
Click for copyable input
Out[1]=
Out[1]=
Out[1]=

In the dialog you can look at the evaluation stack:

In[2]:=
Click for copyable input
(Dialog) Out[2]=

This returns from the first dialog:

In[3]:=
Click for copyable input

Another dialog has started:

In[4]:=
Click for copyable input
(Dialog) Out[4]=

In the dialog, you can check evaluations to see if they come out as you expect:

In[5]:=
Click for copyable input
(Dialog) Out[5]=
In[6]:=
Click for copyable input
(Dialog) Out[6]=

Return from the second dialog. Since there are no more additions, the evaluation will finish:

In[7]:=
Click for copyable input
New in 2
New to Mathematica? Find your learning path »
Have a question? Ask support »