Suppose MyApp`Func1 is a function inside the package MyApp. How do I prevent Trace[Func1[x]] from displaying everything inside Func1 (or what's inside any MyApp functions)?

SetAttributes[MyApp`Func1, {ReadProtected, Locked}] appears to do the job. but then I can't modify options of Func1 with SetOptions.

  • $\begingroup$ What do want Trace[Func1[x]] to display if not the functions that are called inside it? After all, that's what Trace is for. $\endgroup$ – m_goldberg Jul 23 '17 at 6:00
  • $\begingroup$ Why can't you? Unless you set it Protected there should be no problem. $\endgroup$ – Kuba Jul 23 '17 at 6:12
  • $\begingroup$ It sounds like you know the solution: use a different public Symbol for the Options, and pass those to the Locked function that you don't want read. $\endgroup$ – Mr.Wizard Jul 23 '17 at 6:59

Just use the TraceOff option:

Func1[x_] := 2+2
Trace[Func1[x], TraceOff->_Func1]


If you want to kill off tracing of a whole package, you could use something like:

Trace[expr, TraceOff -> (h_[___] /; Context[h]==="MyApp`")]
  • $\begingroup$ That is very helpful. Do you know how to use the related $TraceOff symbol? I tried setting it to the pattern you suggested, but it didn't work for me. $\endgroup$ – QuantumDot Jul 23 '17 at 20:39
  • $\begingroup$ Doing $TraceOff=patt; Trace[expr] will not work because Trace sets $TraceOff to None (the default value of TraceOff). $\endgroup$ – Carl Woll Jul 23 '17 at 22:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.