MathGroup Archive 1998

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

Search the Archive

Re: Question about how Contex resolving works in Mathematica

  • To: mathgroup at
  • Subject: [mg15202] Re: Question about how Contex resolving works in Mathematica
  • From: tgayley at (Todd Gayley)
  • Date: Tue, 22 Dec 1998 04:01:34 -0500
  • Organization: MCSNet Services
  • References: <75f97p$>
  • Sender: owner-wri-mathgroup at

On 18 Dec 1998 23:14:49 -0500, ozan at (Ozan Oektem) wrote:

>  I have real big problems understanding how Mathematica handels
>Contexts. Let me give an example to illustrate the things I can't

You ask a number of questions and document a lot of behavior. I won't
answer the specific questions or explain why all the things you see
happen, because it's not necessary and would probably just obscure the
simple message.

Your packages use "hidden import". I believe this expression was coined,
or at least made commonplace, by Roman Maeder in his seminal book
"Programming in Mathematica". The first edition of that book was
written during the Mathematica 1.x days, and it was correct at the
time. However, with Mathematica 2.0, the behavior of package loading
changed in a fundamental way (for example, the global variable
$Packages was introduced), and this broke hidden import.

It is always a bug to use hidden import, defined as the appearance of
Needs anywhere between BeginPackage and EndPackage. If you do this, you
absolutely guarantee that your package will break, and be broken by,
any other package that uses the packages that you import, often in very
mysterious ways.

The bottom line:

1) Never, ever, use Needs in a package (i.e., between BeginPackage and

It follows that:

2) For every symbol from another package that you want to use in your
package, you must put that symbol's context in your BeginPackage call.

--Todd Gayley

  • Prev by Date: Re: FW: Re: Frequencies function
  • Next by Date: Re: combinations of n objects 2 at a time
  • Previous by thread: Question about how Contex resolving works in Mathematica
  • Next by thread: FW: Re: Frequencies function