Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1995
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1995

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

Search the Archive

Re: Problem with Contexts

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg398] Re: [mg393] Problem with Contexts
  • From: pelle at ic.chalmers.se (Per Ericsson)
  • Date: Wed, 11 Jan 1995 09:05:30 +0100

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

This behavior (not bug) is described on page 341 in the Mathematica book.
In essence, context changes only affect expressions following this complete
expression. Hence calculations made on the same line as the context change
reference the 'old' context.

Hope I made my self clear enough.


/----------------------------------------------------/
/        Per Ericsson                                /
/        Solid State Electronics                     /
/        Chalmers University of Technology           /
/        412 96 Gothenburg, SWEDEN                   /
/                                                    /
/        pelle at ic.chalmers.se                        /
/ Tel.   ++46 31-772 18 63                           /
/ Fax.   ++46 31-772 36 22                           /
/----------------------------------------------------/




  • Prev by Date: mma2html program
  • Next by Date: RE Bin <-> Decimal conversion
  • Previous by thread: Problem with Contexts
  • Next by thread: Re: Problem with Contexts