Mathematica How to Reset $MessageList in Wolfram Language?

  • Thread starter Thread starter Swamp Thing
  • Start date Start date
AI Thread Summary
To reset $MessageList during a computation in Wolfram Language, it is necessary to first unprotect it, as attempts to directly assign or clear it will result in an error due to its protected status. The correct method involves using Unprotect[$MessageList] to remove the protection, followed by setting $MessageList to an empty list with $MessageList = {}. After making the change, it is important to reapply protection with Protect[$MessageList]. This approach is noted as particularly useful, as the protected tag can hinder various use cases in computations.
Swamp Thing
Insights Author
Messages
1,028
Reaction score
765
In the "Details" section here...

https://reference.wolfram.com/language/ref/$MessageList.html

... it says you can reset $MessageList during a computation. I tried $MessageList = {} and Clear[$MessageList] but it says "the tag is protected".

So how can we reset $MessageList?
 
Physics news on Phys.org
You can unprotect it first:
Code:
Unprotect[$MessageList];
$MessageList = {};
Protect[$MessageList];
 
  • Like
  • Informative
Likes berkeman and Swamp Thing
Thank you!
That's very handy to know -- there can be more use cases where the "protected tag" thing gets in the way.
 
Back
Top