Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trouble redefining Protected symbols and system functions [duplicate]

Found trying to use the usual trick to redefine GaussianFilter[ ]:

out[x_]:=Print["(*"<>ToString@x<>"*)"];
(* Redefining Circle[ ] works as expected*)
Unprotect[Circle];
Circle[a_,args__]:=
      Block[{$i=True},{"Circle",a}]/;!TrueQ[$i];
Protect[Circle];
out@Circle[{0,1},1,{0,2Pi}]

(*{Circle, {0, 1}}*)

(* Redefining GaussianFilter[ ] does not*)
Unprotect[GaussianFilter];
GaussianFilter[a_,args__]:=
              Block[{$j=True},{"GaussianFilter",a}]/;!TrueQ[$j];
Protect[GaussianFilter];

SetDelayed::write: Tag GaussianFilter in GaussianFilter[a_,args__] is Protected>>
like image 276
Dr. belisarius Avatar asked Oct 11 '22 01:10

Dr. belisarius


1 Answers

When you run the redefinition the second time, it works fine. Most likely the cause of the problem is the same as discussed here. I can not say that I am fond of this language feature, to say the least.

like image 157
Leonid Shifrin Avatar answered Oct 18 '22 05:10

Leonid Shifrin