This question already has an answer here:
Why do I have to evaluate this twice?

(1个答案)


4年前关闭。




发现尝试使用 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>>

最佳答案

当您第二次运行重新定义时,它可以正常工作。最有可能导致此问题的原因与讨论的here相同。至少可以说,我不能说我喜欢这种语言功能。

关于wolfram-mathematica - 重新定义 protected 符号和系统功能时遇到问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6003224/

10-13 02:21