[an error occurred while processing this directive]
$Context is a global variable that gives the current context.
Contexts are specified by strings of the form "
$Context is modified by Begin, BeginPackage, End and EndPackage.
$Context is a rough analog for Mathematica symbols of the current working directory for files in many operating systems.
See the Mathematica book: Section 2.6.8.
See also: Context.
Every symbol (function or variable) in Mathematica is associated with a context. This allows the same name to be used for different objects, if they belong to different contexts. The sequence of commands below will demonstrate this.
There is a notion of a current context for symbol lookup. Here is the current context when you start Mathematica.
The following name does not exist in memory yet. When you refer to it, a new symbol is created and is assigned to the current context.
This is the context to which the new symbol belongs.
This is its full name.
Assigning a new value to $Context changes the current context. Notice that the context name is a string ending with a backquote.
When you refer to a name that has not been used before, once more a new symbol is created and assigned to the current context.
This is its full name.
We change the context yet again.
The symbol we created in the Global` context is still accessible under its short name, because Global` is in the context search path, as explained in the Further Examples for $ContextPath.
The symbol we created in the Temporary1` context is not accessible under its short name, because Temporary1` is not in the context search path.
Information::notfound: Symbol xxyy not found.
Although xxyy is no longer recognized, the symbol is still accessible under its full name.
A reference to xxxx accesses Global`xxxx, while a reference to xxyy creates a new symbol in the current context.
This shows all the symbols currently accessible under short names that start with xx.
This shows all symbols (in all contexts) whose short names start with xx. Note that Temporary1`xxyy and xxyy (which currently stands for Temporary2`xxyy) are completely independent symbols, and can be given different values and rules. When you use the short name xxyy you are referring to one or the other, depending on the current context.
We revert to the default context.
Usually the current context is changed not by means of an assignment to $Context, but rather indirectly, with the Begin command. This is so that the old context can be restored more easily. See the Further Examples for Begin.
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER
FOR THE LATEST INFORMATION.