A Mathematica package is just a file with the .m
or .wl
extension that contains Mathematica expressions. Get
will simply evaluate these expressions.
The "Run Package" button will simply evaluate everything in the package file. It's equivalent to Get["/path/to/mypakcage.m"]
.
The "Update" button rebuilds the Function and Section menus just left of this button.
"File -> Save" will save the file you are editing. It's the same as "Save" in all text editors.
"File -> Install..." will can be used to install packages. Usually this simply means copying the package file to FileNameJoin[{$UserBaseDirectory, "Applications"}]
.
Regarding the question:
In particularly, if I have a notebook that Gets the package, and I make a change to the package, which of these possibilities do I need to invoke in order for the notebook to have access to the changes in the package?
It is important to understand that all Get["file"]
does is evaluate all the expressions in file
. There's nothing more to it. The fact that these expressions are saved in a file with the .m
extension makes no difference to this. You could evaluate the same expressions in a notebook instead of using Get
to read them from a file, and the effect would be the same.
This gives you the answer to your question. Re-loading the package either with Get
or the Run package
button may or may not correctly update the functions in the package, depending on what was changed.
If you had f[x_] := x
and change it to f[x_] := x^2
, then it will override the previous definition.
If you had f[x_] := x
and change it to f[x_, y_] := x*y
, this will just add an extra definition for f
without removing the previous one. This is clear once we understand that all we're doing is evaluating one definition after the other.
If you follow the standard package structure, localizing everything to a context, then you might use Clear["MyPackage`*"]
to remove the package definitions (all residing in MyPackage`
) before reloading the package.