Files for Packages

When you create or use Wolfram Language packages, you will often want to refer to files in a system-independent way. You can use contexts to do this.

The basic idea is that on every computer system there is a convention about how files corresponding to Wolfram Language contexts should be named. Then, when you refer to a file using a context, the particular version of the Wolfram Language you are using converts the context name to the file name appropriate for the computer system you are on.

Using contexts to specify files.

This reads in one of the standard packages that come with the Wolfram System:

<<Quaternions`

The typical sequence of files looked for by <<name`.

The Wolfram Language is set up so that <<name` will automatically try to load the appropriate version of a file. It will first try to load a name.mx file that is optimized for your particular computer system. If it finds no such file, then it will try to load a name.m file containing ordinary system-independent Wolfram Language input.

If name is a directory, then the Wolfram Language will try to load the initialization file (RefLink[init.m, paclet:ref/file/init.m]) in that directory. The purpose of the (RefLink[init.m, paclet:ref/file/init.m]) file is to provide a convenient way to set up Wolfram Language packages that involve many separate files. The idea is to allow you to give just the command <<name`, but then to load (RefLink[init.m, paclet:ref/file/init.m]) to initialize the whole package, reading in whatever other files are necessary.