Here is my attempt. The sample code with embedded Echo is this:
Module[{}, x = Sqrt[2]; If[myEchoQ, Echo[x]]; N[x]]
The flag is called myEchoQ
. When myEchoQ
is set to False
, no echo is generated and no unnecessary evaluation of x
is made, because If
has the HoldRest
attribute:
myEchoQ = False;
Module[{}, x = Sqrt[2]; If[myEchoQ, Echo[x]]; N[x]]
When myEchoQ
is set to True
, an echo is generated:
myEchoQ = True;
Module[{}, x = Sqrt[2]; If[myEchoQ, Echo[x]]; N[x]]