Mathematica 9 is now available
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: Context confusion

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg1545] Re: Context confusion
  • From: withoff (David Withoff)
  • Date: Sat, 24 Jun 1995 03:17:43 -0400
  • Organization: Wolfram Research, Inc.

In article <3sad49$7jd at news0.cybernetics.net> REECE_D <REECE+_D%A1%Electromagnetic_Sciences at mcimail.com> writes:
>   Back to my context confusion question.  I think it is behaving like I 
>originally thought so my question still exists.  Maybe someone can read 
>this example and explain why I am confused:
>   
>   BeginPackage["Thermal`", "Packages`Miscellaneous`Units`",
>   "Packages`Miscellaneous`SIUnits`", "Global`"];
>   
>   Needs::nocont: 
>      Warning:Context Packages`Miscellaneous`Units`
>        was not created when Needs was evaluated.
>   Needs::nocont: 
>      Warning:Context Packages`Miscellaneous`SIUnits`
>        was not created when Needs was evaluated.
>   
>   Options[Grashof] = {Temperature->300 Kelvin}
>   
>   Kelvin::shdw: 
>      Warning: Symbol Kelvin appears in multiple contexts 
>       {Thermal`, Miscellaneous`SIUnits`}; definitions in
>        context Thermal` may shadow or be shadowed by other
>        definitions.
>   
>   According to Maeder's Book(p.31) "When Mathematica encounters a symbol 
>in the input that you type or that is read from a file, it searches the 
>current context and then all the contexts on the context path for this 
>symbol."  Why then does MMA create 2 versions of Kelvin when both contexts 
>are on the $ContextPath?
>   
>   Related question, how do I leave SIUnits off of the explicit calls but 
>have it appear in the $ContextPath as a result of the call to Units?
>   
>   I am really confused over something I thought I understood somewhat.
>   
>   Thanks in advance,
>   Daryl

************************************************

Probably things will work better if you replace
"Packages`Miscellaneous`Units`" by "Miscellaneous`Units`"
and "Packages`Miscellaneous`SIUnits`" by "Miscellaneous`SIUnits`".

The context created by the Miscellaneous`Units` package, and the
context of the symbols created by that package, is Miscellaneous`Units`.
Similarly, the context created by the Miscellaneous`SIUnits` package,
and the context of the symbols created by that package, is
Miscellaneous`SIUnits`.  Neither of these contexts will be on
the context search path ($Context and $ContextPath) after
evaluation of

  BeginPackage["Thermal`", "Packages`Miscellaneous`Units`",
  "Packages`Miscellaneous`SIUnits`", "Global`"];

so the symbols created by these packages will not be found.  These
contexts will, however, be exposed by a subsequent EndPackage statement,
so the shadow message is generated if you enter a symbol that has
the same short name as the name of a symbol in one of those contexts.

Since the Packages directory that contains these packages is not
by default explicitly on the file search path, it is only by
coincidence that the packages are loaded at all.

Dave Withoff
Research and Development
Wolfram Research


  • Prev by Date: Re: Context confusion
  • Next by Date: Re: LOGARITHMIC AXES
  • Previous by thread: Re: Context confusion
  • Next by thread: Re: A/S Wavefunction calcs: more