Logic of Internal Messages

I am trying to figure out the logic of behavior Message.

Consider the following estimate:

On[]
Sin[1,1]

After rating above you will get about 830 (!) Messages(In Mathematica 7).

All these Messagesarose at creation:

Sin::argx: Sin called with 2 arguments; 1 argument is expected. >>

(this is one, but the last Message).

Last Message

Message::trace: Message[Sin::argx,Sin,2] --> Null. >>

corresponds to the shutdown of the internal function of Mathematica Message. Most others Messagesgo from rating $NewMessageand $MessagePrePrint.

My questions:

1) Why is there no endless generation cycle Message? If a call Message[Sin::argx,Sin,2]creates more than 830 others Messages, why does not each of them produce a similar number Messages? How can this behavior be modeled (by writing an analog Message)?

2) Message Messages, ( On[])?

+4
2

, Message, :

Unprotect[Message];
Message[_, HoldForm[Block[List[$MyMagicalTag$, ___], _]], _] := Null;
Message[args___] /; 
   Block[{$MyMagicalTag$, Message}, Not@TrueQ[inMsg]] := 
  Block[{$MyMagicalTag$, inMsg = True, lastargs = HoldComplete[args]},
    Message[args]];
Message[args___] /; 
   Block[{$MyMagicalTag$, 
     Message}, (inMsg && (HoldComplete[args] =!= lastargs))] := Null;
Protect[Message];

, :

In[6]:= On[]
In[7]:= Sin[1,1]//AbsoluteTiming
During evaluation of In[7]:= Message::trace: Message[Sin::argx,Sin,2] --> Block[{$MyMagicalTag$,inMsg=True,lastargs=HoldComplete[Sin::argx,Sin,2]},Message[Sin::argx,Sin,2]]. >>
During evaluation of In[7]:= Sin::argx: Sin called with 2 arguments; 1 argument is expected. >>
During evaluation of In[7]:= AbsoluteTiming::trace: AbsoluteTiming[Sin[1,1]] --> {0.1502160,Sin[1,1]}. >>
Out[7]= {0.1502160,Sin[1,1]}

, - , .

:

In[8]:= 1+1//AbsoluteTiming
During evaluation of In[8]:= Plus::trace: 1+1 --> 2. >>
During evaluation of In[8]:= AbsoluteTiming::trace: AbsoluteTiming[1+1] --> {0.0400576,2}. >>
Out[8]= {0.0400576,2}

Mr.Wizard .

0

, On. . On " " , . , , , On[]:

On[]; Off[General::trace];
Sin[1, 1]

. , 830 , , :: - , , ...

0

All Articles