I have Echo's buried in code all over my notebook, I'd like a flag to turn them all on or off globally.
- Sure
Unprotect[Echo];Echo=Identity
would disable them, but then you can't re-enable them - A solution that works for all the various types of Echos (EchoName, EchoEvaluation, ...) would be nice
QuietEcho
doesn't work because I'd have to write it add it around every blob of code
Echo=.
, no? $\endgroup$Echo = #&
instead, sinceEcho
can take multiple arguments. $\endgroup$Echo[
withmyEcho
in your code, then at the top assign an appropriate value tomyEcho
, i.e.myEcho = Echo
vs.myEcho = Identity
depending on what you want. The global search should be relatively safe and painless, sinceEcho
is not a common keyword in other function names. This would also work with all othertypes of Echo
, turning them intomyEcho...
versions if you wanted. $\endgroup$Echo
being one of the autoloaded symbols. Check, e.g. on a fresh kernel, this:OwnValues[Echo]
, you will see something like{HoldPattern[Echo] :> System`Dump`AutoLoad[Hold[Echo], Hold[Echo, EchoFunction], "Language`Echo`"] /; System`Dump`TestLoad}
. So, initially,Echo
hasOwnValues
. When you executeEcho[0]
(actually, justEcho
is enough), you cause that definition to run. As a result,OwnValues[Echo]
get cleared, insteadDownValues[Echo]
get populated. When you doEcho = Identity
without auto-load, you hopelessly overwrite autoload code. $\endgroup$