0

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?

  • http://www.gap-system.org/Contacts/Forum/forum.html is probably a better place to ask such questions. – user3733558 Mar 30 '21 at 09:24
  • Did you test ReadPackage( [name, ]file ) or RereadPackage( [name, ]file ) (I'm not sure if it does what you want but I cannot really test this) https://www.gap-system.org/Manuals/doc/ref/chap76.html – thibo Mar 30 '21 at 10:17

1 Answers1

2

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.

ahulpke
  • 18,416
  • 1
  • 21
  • 38
  • I also recommend to use tests - many GAP packages have them in the tst directory, for example see the Example package at https://github.com/gap-packages/example/tree/master/tst. Instead of continuing in the same GAP session with multiple reloads, you can leave that to the situations when you need to test the code interactively, otherwise gap tst/testall.g starts new clean session, loads your package, runs tests and reports discrepancies, if any. – Olexandr Konovalov Mar 30 '21 at 17:27
  • See also https://www.gap-system.org/Manuals/doc/ref/chap76.html#X8559D1FF7C9B7D14 and https://carpentries-incubator.github.io/gap-lesson/04-testing/index.html – Olexandr Konovalov Mar 30 '21 at 17:31