# Unsetting messages

The following code suggests that Mathematica stores the messages in cache:

(*1*)Remove[VariationalD]
(*2*)Messages[VariationalD]
(*3*)Message[VariationalD::args, OPS]
(*4*)Messages[VariationalD]


The output of the second line is {} as expected for a symbol that has just been removed. The output of the third line however is not the expected "-- Message text not found --". Instead, Mathematica seems to have pulled that message from some cache.

In any case, how can I reset the message cache (without resetting the whole installation)?

Update

I apologize because my previous example did not really work. In any case, the following is a better example. This code was executed on a freshly launched kernel.

before = Messages[General]; Message[General::dummies, OPS];
after = Messages[General]; Complement[after, before]


The message General::dummies was not part of the original list of messages attached to General. Following the documentation, the next place to check would be $NewMessage, but Messages[$NewMessage] is empty. So, where did General::dummies come from?

-
You could do Messages[VariationalID] =. ... BTW I can't reproduce the problem you mention. –  Szabolcs Nov 15 '13 at 22:10
@Szabolcs: Messages[VariationalID] =. did not work. The message might need to be loaded into the cache by loading the package. Once in the cache, it seems to stay there. –  Hector Nov 15 '13 at 22:20
I had a typo which you copied and pasted. –  Szabolcs Nov 15 '13 at 22:23

Mathematica loads many of its built-in messages from the file

FileNameJoin[{$InstallationDirectory,"SystemFiles","Kernel","TextResources","English","Messages.m"}]  As I understand it is the "message cache" you seek. The search in this file can be controlled through the $NewMessage variable. By default its value is Automatic:

ClearAttributes[$NewMessage, {Protected, ReadProtected}] Definition@$NewMessage


$NewMessage = Automatic By unsetting it you can disable search in the above-mentioned file as well as in other files in that folder: $NewMessage =.


Also, you can be interested in this discussion: "How to find a specific error message?"

-

This is not a bug.

There is General::args and VariationalD::args. The former message is a general one that can be issued for any symbol:

Message[boo::args, "something"]

boo::args: something called with invalid parameters.


This can be overridden by setting a message for that particular symbol:

In[5]:= boo::args = "custom message"

In[6]:= Message[boo::args]

During evaluation of In[6]:= boo::args: custom message


You can simply remove all messages associated with a symbol using

Messages[boo] =.


Now try again:

Message[boo::args, "something"]

boo::args: something called with invalid parameters.


This works the same way for VariationalD.

Quoting from the Message documentation,

Given a message specified as symbol::tag, Message first searches for messages symbol::tag::Subscript[lang, i] for each of the languages in the list $Language. If it finds none of these, it then searches for the actual message symbol::tag. If it does not find this, it then performs the same search procedure for General::tag. If it still finds no message, it applies any value given for the global variable $NewMessage to symbol and "tag".

-
In the documentation of $NewMessage, I found "A typical value for$NewMessage might be Function[ToExpression[FindList[files,ToString[MessageName[#1,#2]]]]]." This tells me that Mathematica can be set up to look into your packages to find messages. –  Hector Nov 16 '13 at 2:39