11
$\begingroup$

After the usual and well-known warning

General::compat: "Combinatorica Graph and Permutations functionality has been superseded 
by preloaded functionality..."

that was present in version 10, a new warning appears:

SetDelayed::write: "Tag Element in a_List \[Element] {index___} is Protected."

This seems to be potentially serious.

Which statement in Combinatorica causes it, and what are the consequences?

Edit 2016/09/10: Found it.

Combinatorica contains a function Element:

Element[a_List, {index___}] := a[[index]]    

The function Element in the environment System` has the following added Information:

Element[patt, dom] asserts that any expression matching the pattern patt is an element of dom. The use of the function Element in Combinatorica is now obsolete, though the function call Element[a, p] still gives the pth element of nested list a, where p is a list of indices.

So why do some users not get the warning/error but I do?

$\endgroup$
  • $\begingroup$ I only get the first warning on Linux. $\endgroup$ – b.gates.you.know.what Aug 26 '16 at 17:20
  • $\begingroup$ I use "11.0.0 for Microsoft Windows (64-bit) (July 28, 2016)" $\endgroup$ – Wouter Aug 26 '16 at 17:30
  • $\begingroup$ line 1 : DeleteCases[Names["@*"], str_ /; StringMatchQ[str, "$*"] || StringMatchQ[ToString[FullForm[str]], "Formal"]]; line 2: << Combinatorica`; $\endgroup$ – Wouter Aug 29 '16 at 19:08
  • $\begingroup$ This is very strange. I can reproduce the problem after restarting Mathematica fully, including the front end. Then loading Combinatorica triggers the error. Loading it again is fine. From now on the error won't show even if I restart the kernel. It is necessary to restart the Front End too to let the error happen again. What's also strange is that Combinatorica does Unprotect the symbol Element, yet something either prevents this or restores the protected status. I suspect an interaction with auto-completion in the front end and setting the usage message on Element. $\endgroup$ – Szabolcs Sep 10 '16 at 20:34
  • $\begingroup$ This looks like something that is worth reporting to Wolfram Support. Can you do that please? $\endgroup$ – Szabolcs Sep 10 '16 at 20:35
10
+100
$\begingroup$

When the first message is generated, the message formatting code is autoloaded from .mx files. This may cause the attributes of certain symbols to be reset, or rather replaced with what has been stored in one of those .mx files.

A minimal example that can also be run in a standalone kernel

In[1]:= Unprotect[Element]; Attributes[Element]

Out[1]= {}

In[2]:= IntervalSlider; 

In[3]:= Attributes[Element]

Out[3]= {Protected}

where the simple mention of IntervalSlider causes the NotebookTools/Controls.mx file to be autoloaded.

For a workaround of the Element problem, it is sufficient to Quiet the message:

 Quiet[Needs["Combinatorica`"], General::compat]

or trigger the autoloading before attempting to load the package:

 IntervalSlider; Needs["Combinatorica`"]

This is also the most likely reason why some users did not see the error: perhaps they already did something in their session (as simple as generating an error message) that triggered the autoload in advance of loading Combinatorica .

|improve this answer|||||
$\endgroup$
  • $\begingroup$ Ah, so the answer is that auto-loading a different symbol actually auto-loads a whole set of definitions (which is actually completely expected), and Element happens to be among them. Combinatorica does mention Element with the intention to auto-load its usage message though. It's a bit strange that mentioning other symbols after already having mentioned Element causes this ... I'll award the bounty a bit before its expiration. $\endgroup$ – Szabolcs Sep 13 '16 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.