重新定义受保护的符号和系统功能时遇到问题
发现尝试使用常用技巧
重新定义 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>>
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>>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您第二次运行重新定义时,它工作正常。问题的原因很可能与此处讨论的相同< /a>.至少可以说,我不能说我喜欢这种语言功能。
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.