MathGroup Archive 2000

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

Search the Archive

Re: functions, packages, and contexts


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


  • Prev by Date: Re: ListPlot
  • Next by Date: Re: MatrixReplace.m
  • Previous by thread: functions, packages, and contexts
  • Next by thread: RE: functions, packages, and contexts