Reloading a package

42 Views Asked by At

I have the following question concerning loading of GAP packages (concerns in the same way both Linux and Windows).

Suppose I have a package named "SamplePackage" located in the pkg directory. After launching a GAP session I load the SamplePackage with

LoadPackage( "SamplePackage" );

and it works fine. My problem is now as follows: I work "live" on the SamplePackage and I make a lot of changes and want to see the effect. Unfortunately after making a change in some of SamplePackage files and loading it again with "LoadPAckage("SamplePackage") in the same GAP session it does not load the update (I guess it is the custom beheviour of GAP). In order to see the update in the package I have to launch a new session and load the package again. It solves the problem but is a littlbe bit annoying as one has to repeat the same command to load the package over and over again.

Is there a way to reload the package in the same GAP session such that the updates are visible?

1

There are 1 best solutions below

2
On BEST ANSWER

Since this is only an issue for a developer of the package, but not for the general user, there is no generic "reload" mechanism. What one can do is to reload individual files with RereadPackage (without causing warnings about objects already having been declared). You could simply reload the file you worked as:

RereadPackage("SamplePackage","/lib/myfile.gi");

If your changes go over multiple files, you could put all these RereadPackage commands into a single file you then read in.

One Caveat: If you re-read a file that includes declarations, these prioperties get re-declared, and there might be some incompatibility with objects you created before re-reading the file.