Re: Question about how Contex resolving works in Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg15202] Re: Question about how Contex resolving works in Mathematica
- From: tgayley at mcs.net (Todd Gayley)
- Date: Tue, 22 Dec 1998 04:01:34 -0500
- Organization: MCSNet Services
- References: <75f97p$7j5@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On 18 Dec 1998 23:14:49 -0500, ozan at matematik.su.se (Ozan Oektem) wrote: >Hi, > > I have real big problems understanding how Mathematica handels >Contexts. Let me give an example to illustrate the things I can't >understand. 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 EndPackage). 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