This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / Built-in Functions / Programming / Scoping  /
Begin

  • Begin[" context `"] resets the current context.
  • Begin resets the value of $Context.
  • The interpretation of symbol names depends on context. Begin thus affects the parsing of input expressions.
  • See the Mathematica book: Section 2.6.10.
  • See also: BeginPackage, End, $ContextPath.

    Further Examples

    This is the current context when you start Mathematica.

    In[1]:=

    Out[1]=

    This is the current context path. A symbol whose context name is not specified is looked up first in the current context, then in the contexts in $ContextPath.

    In[2]:=

    Out[2]=

    This command changes the current context, but not the context path.

    In[3]:=

    Out[3]=

    The following symbol does not exist either in the current context Temporary`, or in the contexts in $ContextPath. As a result, it is created in the current context.

    In[4]:=

    Out[4]=

    This is its full name.

    In[5]:=

    Temporary`newsymbol

    Following this command, the earlier context is restored.

    In[6]:=

    Out[6]=

    Now newsymbol is not recognized, since the context it belongs to is not in the search path.

    In[7]:=

    Information::notfound: Symbol newsymbol not found.

    A very common use of Begin is to hide symbols defined in packages. This technique is illustrated in the Further Examples for BeginPackage.