Loading a package may result in shadowed symbols. Here is what to do about it.

Define a symbol or function

Define the symbol A1:

In[1]:=
Click for copyable input
Out[1]=

New symbols are created in the Global` context by default:

In[2]:=
Click for copyable input
Out[2]=

Load a package

Load the Music package. That package defines the symbol A1 in the Music` context, which shadows the previously defined symbol Global`A1:

In[3]:=
Click for copyable input

Now A1 refers to the symbol in the Music` context:

In[4]:=
Click for copyable input
Out[4]=

The value of A1 in the Music` context differs from the value in the Global` context. The red coloring indicates that the Global`A1 symbol is shadowed:

In[5]:=
Click for copyable input
Out[5]=

The previously defined value of A1 can be accessed by specifying its context explicitly:

In[6]:=
Click for copyable input
Out[6]=
  • Shadowing means that the same symbol occurs in more than one context on the context path, $ContextPath, making one or more symbols inaccessible unless you specify an explicit context. See the Contexts and Packages tech note for detailed information.

Resolve the shadowing

Remove the shadowed symbol to resolve the shadowing:

In[7]:=
Click for copyable input

The A1 symbol is no longer colored red, indicating that it is no longer shadowing any other symbols:

In[8]:=
Click for copyable input
Out[8]=

Notes

Avoid shadowing by adhering to the convention that user-defined symbols and functions begin with lowercase letters.
Shadowing does not necessarily involve user-defined symbols. If two packages define the same symbol, loading both in the same session will result in shadowing. In that case, either of the symbols can be removed to resolve the shadowing.