MathGroup Archive 2012

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

Search the Archive

Re: Packages - trivial question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg125198] Re: Packages - trivial question
  • From: "djmpark" <djmpark at comcast.net>
  • Date: Tue, 28 Feb 2012 00:45:52 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <25034517.5735.1330343203016.JavaMail.root@m06>

Jakub,

It's a Context mark and picks up its meaning by being attached to a Symbol
instead of a number.

It rather serves a double purpose and this creates a bit of confusion.

1) It gives the path from standard Mathematica starting folders to the
packageCode.m code that exports various symbols. The path is
applicationFolder`packageCode.m
2) It gives the context for those symbols. (Such as Global` is the context
for normal user defined symbols and System` is the context for Mathematica
defined symbols.)

What most people call a "package" should actually be called an
"application". A package is a file that contains code that adds
functionality for users. An application is a larger entity, contained in a
folder, that contains one or more packages, plus documentation, palettes,
style sheets and other possible material such as a book. It also usually
contains an init.m file that is evaluated when the application is loaded. An
application is, in my opinion, the absolutely premier method for
communicating technical material to other people who have Mathematica.

If the packageCode name is different than the application name, then the
path and the context are the same. Normally a package would be loaded by a
binary context name:

<< applicationFolder`packageCode`

with two context marks. But in most cases the full path is hidden from
users. This is because if an application is loaded with a single context
then Mathematica looks for and evaluates a Kernel/init.m file in the
application. The init.m file contains the actual code that loads the
package.

For example the AuthorTools package is in the Wolfram AddOns/Applications
folder. When you attempt to load an application this is one of a number of
places that Mathematica looks for the package. The AuthorTools application
contains a number of packages with various names, one of them being
Common.m. You would load the application with:

<< AuthorTools`

Mathematica then evaluates the init.m file in AuthorTools/Kernel. This
contains a series of DeclarePackage statements that control the loading of
the various packages. (An alternative would be for init.m to simply load
each of the packages.)

The context for a specific symbol, say AddCellTags, is:

Context[AddCellTags] 
AuthorTools`Common`

It is the path name to the symbol.

However (and this is where things get a little confused) if the application
contains only one package and its name is the same as the application
folder, then Mathematica truncates the context to a single context mark. For
example, the PhysicalConstants application is in the Wolfram AddOns/Packages
folder. (Another place that Mathematica automatically looks) Its init.m file
contains the single statement that contains the full path name. So

<<PhysicalConstants`

actually causes the following load statement to be evaluated.

 Get["PhysicalConstants`PhysicalConstants`"]

But the context of any symbols in the application drops one of the names.

Context[SpeedOfLight]
PhysicalConstants`

Another confusion is that the documentation for  the applications in the
Packages folder is not with the applications, but is contained in the
Mathematica/8.0/Documentation folder.

One other caveat. If you are designing an application or using a standard
third party application, the preferred place to put it is in the
$UserBaseDirectory/Applications folder or possibly the
$BaseDirectory/Applications folder, and not in the Wolfram files.
Mathematica also automatically looks in these places and the application
will be preserved over various versions of Mathematica.


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/index.html


From: =A9er=FDch Jakub [mailto:Serych at panska.cz]


I'm sorry for such a trivial question, but what does mean the backapostroph
behind the package name, when one wants to get package?

For example:
<< PhysicalConstants`

I'm trying to find it in the documentation, but I'm not successfull.  Is it
the same symbol as it is used for NumberMarks i.e. 0.3333333333333333` for
example?

I think, that in the case of packages it means something like "definition
space", because for example:
Remove["Global`*"] should remove all the symbol definitions in current
session.

But I'm still confused of the little but magic  `

Thanks in advance for any enlightenment

Jakub





  • Prev by Date: Re: Plotting colorfunctions over multiple parametric curves
  • Next by Date: Re: Blank plot returned from simple expression
  • Previous by thread: Re: Packages - trivial question
  • Next by thread: Plotting colorfunctions over multiple parametric curves