MathGroup Archive 2005

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

Search the Archive

Re: Packages with Cyclic Dependencies

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63264] Re: [mg63219] Packages with Cyclic Dependencies
  • From: "David Park" <djmp at earthlink.net>
  • Date: Tue, 20 Dec 2005 23:35:50 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Catarina,

I haven't actually tried that, but I don't see why it wouldn't work. In any
case, try it out. You could also use BeginPackage["A`",{"B`"}]. When the
packages are read in, Mathematica is just establishing the names and
definitions. It doesn't try to evaluate any of the routines until you
evaluate them from a notebook at which time all the definitions and names
are known.

Making the cells initialization cells and using the AutoSave Package feature
is the best way to make a package. If you edit the package.nb the package.m
file will automatically be updated upon saving. You should never have to
look at or edit the package.m file.

One more thing. You might want to put you package in a standard place. The
best place is to evaluate $BaseDirectory or $UserBaseDirectory to find the
place, outside of the Wolfram files, to store packages. That will give you a
Mathematica folder and within that folder there should be an Applications
folder. Create a name for your application, QuantumGravity, say. Then create
a folder QuantumGravity in the Applications folder. Put your packages in the
QuantumGravity folder and make the BeginPackage statement...

BeginPackage["QuantumGravity`A",{"QuantumGravity`B"}]

Then the package would be loaded by

Needs["QuantumGravity`A`"] and
Needs["QuantumGravity`B`"]

Within the QuantumGravity folder you could also have Documentation\English
folders if you wanted to add Help pages to the Help Browser and you could
have FrontEnd\Palettes and FrontEnd\StyleSheets if you wanted to have
palettes and style sheets that went with the application. Mathematica will
know how to find all of these things if QuantumGravity is in the
Applications folder. And if you update Mathematica the application will
still be there and work.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/


From: katy [mailto:mcld at mega.ist.utl.pt]
To: mathgroup at smc.vnet.net


Hi all,

Using Mathematica 5.1.
I have two packages, let's call them A and B and they both need each
other, something like:
A.m:
BeginPackage["A`"]
Needs["B`"]

...

EndPackage[]

B.m:
BeginPackage["B`"]
Needs["A`"]

...

EndPackage[]

Can I have this kind of cyclic package dependency?
Now, my current package design is, I write the packages in a notebook
and mathematica seems to create the .m automagically. Should this be
this way? I never get to touch the .m?


Thanks,

Catarina Dias



  • Prev by Date: Re: Gray's Differential Geometry error?
  • Next by Date: Re: Speeding up simple Mathematica expressions?
  • Previous by thread: Re: Packages with Cyclic Dependencies
  • Next by thread: Re: Cross results?