无法重新定义受保护的符号和系统功能

时间:2011-05-14 16:36:50

标签: wolfram-mathematica

发现尝试使用the usual trick重新定义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>>

1 个答案:

答案 0 :(得分:4)

第二次运行重新定义时,它可以正常工作。问题的原因很可能与讨论的here相同。至少可以说,我不能说我喜欢这种语言特征。