Mathematica How to Reset $MessageList in Wolfram Language?

  • Thread starter Thread starter Swamp Thing
  • Start date Start date
Click For 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,040
Reaction score
774
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.
 

Similar threads

  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 21 ·
Replies
21
Views
6K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
7
Views
2K