MathGroup Archive 2000

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

Search the Archive

RE: Package naming

  • To: mathgroup at smc.vnet.net
  • Subject: [mg24733] RE: [mg24673] Package naming
  • From: "David Park" <djmp at earthlink.net>
  • Date: Wed, 9 Aug 2000 02:31:34 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Jack,

I know that there are different practices, but this is what I like to do.

I like my packages to behave just like the standard Mathematica packages.
WRI has provided a simple way to do this.

I put all my packages in AddOns/ExtraPackages and then create folders there
that parallel the ones that are in AddOns/StandardPackages. You can also
create special folders there for special topics. For example, I have a
folder named DifferentialGeometry where I put packages related to that
subject. This way, your packages, or any packages you get from others who
follow this scheme will behave just like standard packages, but will be kept
separate from the standard packages. Mathematica automatically looks in
AddOns/ExtraPackages.

Suppose that you find that your package would best be grouped with Calculus`
packages. Then create a folder named Calculus in AddOns/ExtraPackages. Place
the notebook that creates the package there. The name of this notebook will
be PiecewiseContinuous.nb. If you have made all the cells initialization
cells, and choosen the Autosave feature, then when you save it, a package
file with the name PiecewiseContinuous.m will also be created there. Anytime
you update the notebook, the package will be updated.

Here is the slightly tricky part, which is not well documented (as far as I
could find). Write your BeginPackage statement this way:

BeginPackage["Calculus`PiecewiseContinuous"]

In other words you have to give the path from ExtraPackages on down.

Then it should work just like the standard packages.

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

> -----Original Message-----
> From: Jack Goldberg [mailto:jackgold at math.lsa.umich.edu]
To: mathgroup at smc.vnet.net
>
> Hi once again,
>
> I need some help.
>
> I have just completed designing a package that tries to incorporate
> piecewise continuous functions seamlessly into Mathematica.  Naturally, I
> entitle the package  PiecewiseContinuous.  So, I want the user
> to be able to call this package by
>
> Needs["PiecewiseContinuous`"]
>
> or
>
> <<PiecewiseContinuous`
>
> just the way I can call  <<Algebra`    or    Needs["Collatz`"]  to get
> these to Packages to load.  (I know the difference between <<  and Needs;
> I use them both here to illustrate my problem.)
>
> Now the problem ...
>
> What do I put as the argument of BeginPackage[?] and where should the
> package be stored so that the call to load it is not too different from
> <<PieceWiseContinuous` ? I have a feeling these are related questions and
> the answer hinges on ContextPaths.   I might
> add that none of the books I have consulted directly address this issue.
> (I have a rather large library of Mathematica books by the way.)
> For instance,
> Maeder gives a host of examples in his book Programming in Mathematica.
> Here is one
>
> BeginPackage["RandomWalk`"]
> ...
>
> EndPackage[]
>
> but does not hint at where and how to store this package so that it can
> be loaded with the call  <<RandomWalk` .
>
> My best quess is this:  If the user (say me) stores the package in a
> folder `mypackages,  then the correct call to load PiecewiseContinuous is
> Needs["mypackages`PiecewiseContinuous`"]  since this will tell
> Mathematica where
> to look for this function.  Is this right?
>
> Thanks all.  Learning Mathematica on my own tends to leave me
> with large gaps in
> my knowledge- or at least in my confidence.
>
>
> Jacl
>
>
>
>
>
>
>



  • Prev by Date: Re: Mathematica won't solve simple diff. eqn.--Correction
  • Next by Date: Re: 2D array to tab delimited file
  • Previous by thread: Re: Package naming
  • Next by thread: A simple problem