`"] makes context
` and System` the only active contexts.
] calls Needs on the .
BeginPackage is typically used at the beginning of a Mathematica package.
BeginPackage resets the values of both $Context and $ContextPath.
The interpretation of symbol names depends on context. BeginPackage thus affects the parsing of input expressions.
See the Mathematica book: Section 2.6.10.
See also: EndPackage.
BeginPackage sets things up so that only System` and the named context are in the context search path. As a result, any reference to something other than a predefined symbol creates a new symbol in the named context.
The corresponding EndPackage restores the earlier environment, and also adds to the $ContextPath the context that's being concluded. As a result, symbols created between the invocations of BeginPackage and EndPackage are now accessible under their short names.
A package often needs to use variables and functions that should not be accessible by their short names ("private" symbols). Such symbols are traditionally created inside a subcontext of the context created by BeginPackage. Here is a full example illustrating the standard sequence of context control commands.
This makes Collatz` the current context, and puts only System` on the context search path.
This introduces the objects intended to be "exported", that is, made visible after the package is loaded.
This passes to a subcontext. The backquote at the beginning of `Private` stands for the current context.
Here is the definition of the function.
This tells Mathematica to revert to the previous context (here, Collatz`).
This ends the package, prepending Collatz` to the context search path.
Here is the context search path.
The Collatz function was created in the context Collatz`.
The symbol n was put in the private context Collatz`Private`. It is not accessible by its short name, so it won't interfere with other uses for n.
Information::notfound: Symbol n not found.
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER
FOR THE LATEST INFORMATION.