|
[Date Index]
[Thread Index]
[Author Index]
Re: RE: Context
- To: mathgroup at smc.vnet.net
- Subject: [mg71000] Re: [mg70985] RE: [mg70956] Context
- From: Sseziwa Mukasa <mukasa at jeol.com>
- Date: Sat, 4 Nov 2006 04:08:12 -0500 (EST)
- References: <200611030639.BAA21066@smc.vnet.net>
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 metrohm.ch]
To: mathgroup at smc.vnet.net
> 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.
and
> This command changes the current context, but not the context path.
> In[3]:=
> Begin["Temporary`"];
> {$Context,$ContextPath}
>
> Out[3]=
> {Temporary`,{Global`,System`}}
Regards,
Ssezi
- References:
- RE: Context
- From: "Virgilio, Vincent - SSD" <Vincent.Virgilio@itt.com>
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
|