MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: RE: Context

  • To: mathgroup at
  • Subject: [mg71000] Re: [mg70985] RE: [mg70956] Context
  • From: Sseziwa Mukasa <mukasa at>
  • Date: Sat, 4 Nov 2006 04:08:12 -0500 (EST)
  • References: <>

On Nov 3, 2006, at 1:39 AM, Virgilio, Vincent - SSD wrote:

> Below, a CompoundExpression[] contains a Begin[].  I think the Begin[]
> will not affect anything in that CompoundExpression[]. So Mathematica
> creates t in Global` rather than x`, which you see.

The answer is to consider $ContextPath.

> -----Original Message-----
> From: dh [mailto:dh at]
To: mathgroup at
> Subject: [mg71000] [mg70985] [mg70956] Context
> Hello,
> consider:
> fun[x_]:=( Begin[x];
>        Print[t];
>        End[];
>        );
> according to the manual one would think that the variable t in  
> context x

No it will search for t in contexts specified in the context path, if  
there's a DownValue for t specified in a context on the context path  
and none in the current context, then the value in the other context  
will be used.  If you think about this for a second this behavior is  
necessary because most of the built in functions are defined in the  
System` context and if Begin overwrote the context path you'd lose  
all the built in definition when you started a new context.

This explanation is in the further explanation section of the help on  
Begin, specifically:

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


> This command changes the current context, but not the context path.
> In[3]:=
> Begin["Temporary`"];
> {$Context,$ContextPath}
> Out[3]=
> {Temporary`,{Global`,System`}}



  • References:
    • RE: Context
      • From: "Virgilio, Vincent - SSD" <>
  • Prev by Date: Re: Graphics--ContourPlot output varies drastically with PlotPoints.
  • Next by Date: Re: Mathematica / MacOSX / XDarwin fonts problem
  • Previous by thread: RE: Context
  • Next by thread: Re: Context