Skip to main content
Post Merged (destination) from mathematica.stackexchange.com/questions/43619/…
added 1 characters in body
Source Link
István Zachar
  • 47.2k
  • 20
  • 145
  • 293

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):

$ContextPath
{"DocumentationSearch`", "ResourceLocator`", "PacletManager`",
 "QuantityUnits`", "WebServices`", "System`", "Global`"}
WebServices`x;
Begin["temp`"];
Print@Context@x;
End[];
 WebServices`

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

$ContextPath = DeleteCases[$ContextPath, "WebServices`"];
WebServices`x;
Begin["temp`"];
Print@Context@x;
End[];
temp`

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

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):

$ContextPath
{"DocumentationSearch`", "ResourceLocator`", "PacletManager`",
 "QuantityUnits`", "WebServices`", "System`", "Global`"}
WebServices`x;
Begin["temp`"];
Print@Context@x;
End[];
 WebServices`

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

$ContextPath = DeleteCases[$ContextPath, "WebServices`"];
WebServices`x;
Begin["temp`"];
Print@Context@x;
End[];
temp`

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

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):

$ContextPath
{"DocumentationSearch`", "ResourceLocator`", "PacletManager`",
 "QuantityUnits`", "WebServices`", "System`", "Global`"}
WebServices`x;
Begin["temp`"];
Print@Context@x;
End[];
 WebServices`

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

$ContextPath = DeleteCases[$ContextPath, "WebServices`"];
WebServices`x;
Begin["temp`"];
Print@Context@x;
End[];
temp`

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

Source Link
István Zachar
  • 47.2k
  • 20
  • 145
  • 293

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):

$ContextPath
{"DocumentationSearch`", "ResourceLocator`", "PacletManager`",
 "QuantityUnits`", "WebServices`", "System`", "Global`"}
WebServices`x;
Begin["temp`"];
Print@Context@x;
End[];
 WebServices`

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

$ContextPath = DeleteCases[$ContextPath, "WebServices`"];
WebServices`x;
Begin["temp`"];
Print@Context@x;
End[];
temp`

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