无法重新定义受保护的符号和系统函数 [英] Trouble redefining Protected symbols and system functions

查看:16
本文介绍了无法重新定义受保护的符号和系统函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

发现尝试使用常用技巧 重新定义 GaussianFilter[ ]:

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>>

推荐答案

当您第二次运行重新定义时,它工作正常.问题的原因很可能与此处.至少可以说,我不能说我喜欢这种语言功能.

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.

这篇关于无法重新定义受保护的符号和系统函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆