Re: functions, packages, and contexts
- To: mathgroup at smc.vnet.net
- Subject: [mg25036] Re: functions, packages, and contexts
- From: quizzik at yahoo.com (Thomas Anderson)
- Date: Fri, 1 Sep 2000 21:57:42 -0400 (EDT)
- Organization: Stanford University
- References: <8one3u$oh4@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
<< question of how to use packages within other packages >> This is something that gave me a lot of trouble, too. The problem is that when you declare the package using BeginPackage["x`"], the only contexts that are available on the search path are x`, Global` and System`. You want to call other packages; the easiest way to do this is to provide these packages as a second argument to BeginPackage. For example, BeginPackage["x`", {"y`", "z`"}] will begin the "x`" package context, and also put y` and z` on the search path. Then you can use any symbols defined in y` and z` without worrying about the context. There is a reasonably clear explanation of all this in section 2.6.10 of the Mathematica Book. Incidentally, the Mathematica Book indicates that the additional packages to be used must be given as a List. In my experience, however, this doesn't seem to be necessary; i.e. BeginPackage["x`", "y`", "z`"] seems to work just fine. Perhaps someone with more expertise can comment on this. -Tom