Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Section 8.1.1 (P230 of the book, P249 of the PDF) of Wagner's book, the following example is shown:

x = 5;
temp`x = 6;
{x, Global`x}

The output is claimed to be:

{6, 5}

But actually in version 8 and 9, the real behavior is:

enter image description here

Have I missed something, or this example is just outdated?

If so, do there exist other outdated parts in this book? Should we start a collection or something?

share|improve this question

marked as duplicate by Szabolcs, m_goldberg, bobthechemist, R. M. Mar 8 '14 at 19:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

may be you found a bug in the book or a bug in Mathematica :) – Nasser Mar 8 '14 at 9:06
Try this for more strange result: x = 5; Begin["temp"]; x = 6; {x, Globalx} which gives {6,6} ? – Nasser Mar 8 '14 at 9:17
@Nasser - If you use BeginPackage to put temp` on the context path it works, but this demo also needs a line break: x = 5; BeginPackage["temp`"]; (*line break*) x = 6; {x, Global`x} – Chris Degnen Mar 8 '14 at 12:21
The very same question was asked a couple of days ago. At that time I noted that even the current v9 documentation is incorrect because it states that when looking for a symbol that was entered, Mathematica searches $ContextPath after searching $Context, even though in reality it searches $ContextPath before $Context – Szabolcs Mar 8 '14 at 13:48
I wrote another answer there: – Szabolcs Mar 8 '14 at 14:03
up vote 11 down vote accepted

This is because of $ContextPath. If the symbol outside the Begin/End is created in a context that is listed in $ContextPath, Mathematica will recognize it as belonging to that context even when called from a different context (even if Begin/End is put in a package file and called via Get):

{"DocumentationSearch`", "ResourceLocator`", "PacletManager`",
 "QuantityUnits`", "WebServices`", "System`", "Global`"}

Now if I remove "WebServices`" from $ContextPath:

$ContextPath = DeleteCases[$ContextPath, "WebServices`"];

Now what has changed in related code in successive versions, I have no idea.

share|improve this answer

Not an answer. Just screen shot. I booted up version 2.2 to verify the book result. And it does verify.

Mathematica graphics

Mathematica graphics

Something changed since the book was written !

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.