       Re: Problem with Contexts

• To: mathgroup at christensen.Cybernetics.NET
• Subject: [mg400] Re: [mg393] Problem with Contexts
• From: Leendert van Gastel <gastel at can.nl>
• Date: Thu, 12 Jan 1995 13:20:42 +0100

```> I experienced the following problem when defining Contexts:
>
> Mathematica 2.2 for NeXT
> Copyright 1988-93 Wolfram Research, Inc.
>  -- NeXT graphics initialized --
> In:= Begin["Alice`"]
> Out= Alice`
> In:= x=1;y=2;x+y
> Out= 3
> In:= Begin["Bob`"]
> Out= Bob`
> In:= x=11;y=22;x+y
> Out= 33
> In:= Begin["Alice`"];y-x
> Out= 11
> In:= y-x
> Out= 1
> In:= Exit

Dear Charlie,

The change in the context is only effectuated when the command
it is part of, is processed completely.
This happens to be the way that it works, I noticed it once myself.
The full form of a;b is CompoundExpression[a, b], so when
a=Begin["Alice`"], this change is performed after the complete
CompoundExpression is evaluated.

first line:

Begin["Alice`"]; Null

second line:

y-x

The lines that form complete expressions in one cell are processed one by one
and so the change in context is performed after executing the first line.

>
> For the In I try to change the Context and do a calculation in
> the same command, but the calculation is done using the previous
> Context ("Bob"). However, the Context was changed as noted when
> the calculation is repeated (In). Is this a bug or am I missing
> something about how Contexts are used and defined.
>
> BTW--I found the same problem when using the Notebook interface BUT
> when I concatenate the commands on separate lines it works okay--
>
> Begin["Alice"];y-x
>
> doesn't work, but
>
> Begin["Alice"];
> y-x
> (the Shift-Return)
>
> does work.
>
> Thanks for the help,
> Charlie
>
> --
> 	NeXTMail to:		|	...to confer, converse, and
> 	charlie at technosci.com	|	otherwise hobnob with my
> 				|	brother wizards.
>
>

```

• Prev by Date: Re: Bin <-> Decimal conversion
• Next by Date: Re: for Adam RUSSELL HALVORSEN
• Previous by thread: Re: Problem with Contexts
• Next by thread: Get Parts of Expression by Position list