我仍然感到困惑的是,当切换Message
时On[Message]
并不总是被跟踪,而通过评估者调用此函数。
考虑:
In[1]:= On[Message,Plus];
1+1
Sin[1,1]
During evaluation of In[1]:= Plus::trace: 1+1 --> 2. >>
Out[2]= 2
During evaluation of In[1]:= Sin::argx: Sin called with 2 arguments; 1 argument is expected. >>
During evaluation of In[1]:= Message::trace: Message[Sin::argx,Sin,2] --> Null. >>
Out[3]= Sin[1,1]
In[4]:= Unprotect[Message];
Message:=Print[List[##]]&
1+1
During evaluation of In[4]:= {Plus::trace,1+1,2}
Out[6]= 2
很明显,在两种情况下都通过评估者调用Message
,因为可以在顶层拦截调用。但1+1
的情况并未追溯到这一点。为什么呢?