IsPackageMarkedForLoading( "GaussForHomalg" )

From: Alexander Konovalov <alexk@mcs.st-andrews.ac.uk>
Subject: Re: Warning while package loading
Date: 1. Dezember 2013 22:24:32 MEZ
To: Mohamed Barakat <mohamed.barakat@rwth-aachen.de>

Dear Mohamed,

On 1 Dec 2013, at 11:04, Mohamed Barakat <mohamed.barakat@rwth-aachen.de> wrote:

> Dear Alexander,

>> #I  GaussForHomalg: start reading file 'read.g'
>> #I  GaussForHomalg: Do not call `LoadPackage( "gaussforhomalg", ... )' in the package file
>> #I                  /home/hudson/hudson/workspace/GAP-minor-release-test/GAPCOPTS/64build/GAPGMP/gmp/GAPTARGET/packagesload/label/graupius/gap4r7/pkg/GaussForHomalg/gap/GaussRationals.gi,
>> #I                  use `IsPackageMarkedForLoading' instead

>> - that does not cause cause known problems, but may add extra twists to package loading making it harder to debug -
>> it would be good to clean up this eventually.

> I load it in MatricesForHomalg/gap/HomalgRing.gi

Thanks, I've found it:

           if LoadPackage( "GaussForHomalg" ) <> true then
               Error( "the package GaussForHomalg failed to load\n" );
           fi;

(looks to me like the message above is misleading since points to a wrong file).

> At the moment I have to better option as I don’t want MatricesForHomalg to depend on GaussForHomalg;
> namely GaussForHomalg depends on Gauss and the latter does not load if a module is not compiled,
> which some users, or even worse, system admins forget to do. Then no package of the homalg projects is usable.

I think that the GAP package loading mechanism already has all provisions for this reasonable scenario.
All you have to do is to make GaussForHomalg suggested package for MatricesForHomalg, and change the code above to

           if IsPackageMarkedForLoading( "GaussForHomalg" ) <> true then
               Error( "the package GaussForHomalg failed to load\n" );
           fi;

Then GaussForHomalg will be loaded if it's present, and the Error will be triggered at runtime if it's not.

Best wishes
Alex