Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Core Language > Package Development > Namespace Management >

EndPackage

EndPackage[]
restores $Context and $ContextPath to their values before the preceding BeginPackage, and prepends the current context to the list $ContextPath.
  • EndPackage is typically used at the end of a Mathematica package.
Commands to define a simple package:
Modify the context and context path so that symbol creation and lookup use square`:
Here are the commands defining the function in the package:
Restore the context, but leave square` on the context path for symbol lookup:
The context is now the same as the original:
The context path is the same as the original, but with square` prepended:
Commands to define a simple package:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Modify the context and context path so that symbol creation and lookup use square`:
In[3]:=
Click for copyable input
Here are the commands defining the function in the package:
In[4]:=
Click for copyable input
In[5]:=
Click for copyable input
Restore the context, but leave square` on the context path for symbol lookup:
In[6]:=
Click for copyable input
The context is now the same as the original:
In[7]:=
Click for copyable input
Out[7]=
The context path is the same as the original, but with square` prepended:
In[8]:=
Click for copyable input
Out[8]=
Use BeginPackage and EndPackage to start and end a package in a file:
The package can be loaded with Get:
Once loaded, the definitions work:
New in 1
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team