Function Repository Resource:

SetFunctionEcho

Source Notebook

See all evaluations of a given function

Contributed by: Jon McLoone

ResourceFunction["SetFunctionEcho"][fn]

causes all subsequent evaluations of fn to Echo.

ResourceFunction["SetFunctionEcho"][fn,"Off"]

removes the Echo from fn.

Details and Options

Functions with HoldFirst, HoldAll or HoldRest attributes will Echo the unevaluated arguments.

Examples

Basic Examples (2) 

See the HTTPRequests that are constructed during a the evaluation of a ResourceFunction:

In[1]:=
ResourceFunction["SetFunctionEcho"][HTTPRequest];
ResourceFunction["UKPostcodeLookup"]["OX29 8FD"]
Out[2]=

You can cancel the behaviour with:

In[3]:=
ResourceFunction["SetFunctionEcho"][HTTPRequest, "Off"];
ResourceFunction["UKPostcodeLookup"]["OX29 8FD"]
Out[4]=

Options (2) 

Use "EchoOutput" to also see the results of calls to the given function. For example, see the location of temporary files created during ExportString:

In[5]:=
ResourceFunction["SetFunctionEcho"][OpenWrite, "EchoOutput" -> True];
ExportString["Hello", "HTMLFragment"]
Out[6]=

Functions with HoldFirst, HoldAll or HoldRest attributes will Echo the unevaluated arguments:

In[7]:=
ResourceFunction["SetFunctionEcho"][Switch];
Table[Switch[x, _?EvenQ, x^2, _?OddQ, -x], {x, 1, 2}]
Out[8]=

Possible Issues (2) 

Times, Plus and symbols such as $Version that are not applied as functions cannot be used within SetFunctionEcho:

In[9]:=
ResourceFunction["SetFunctionEcho"][Plus];
(3 + 4)*5
Out[10]=

To work around this limitation, one can hide the Plus behind a downvalue:

In[11]:=
myPlus[x_, y_] := x + y
ResourceFunction["SetFunctionEcho"][myPlus]
myPlus[3, 5]
Out[12]=

Publisher

Jon McLoone

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.0.0 – 12 April 2024

Related Resources

License Information