> < ^ Date: Wed, 07 Dec 1994 10:00:00 +0100
> < ^ From: Steve Linton <sal@dcs.st-and.ac.uk >
> < ^ Subject: Re: how are library files used?

06 Dec 94 19:43 -0500
> From: James McCarron <jmccarro@mercator.math.uwaterloo.ca>
> Subject: how are library files used?
> I wonder if someone can explain something about how GAP uses its
> library files (I mean the ones in lib/*.g ). Does GAP need to read the
> appropriate file each time it uses a routine defined in the file, or are the
> functions read when GAP starts up, and stored in memory for the duration of
> the session. In other words, once GAP is started, does it still need these
> library files? I have looked through the source code but it is just too
> vast for me to comprehend.

The place to start looking is lib/init.g which contains many
sections of the form

AUTO( ReadLib( "abattoir" ),
LengthString, SubString, ConcatenationString, Edit, ProductPol, ValuePol,
MergedRecord, UnionBlist, IntersectionBlist, DifferenceBlist, SetPrintLevel,
Save, SetPkgname, PKGNAME, LOADED_PACKAGES, ReadPkg, ExecPkg, LoadPackage,
RequirePackage, OpsOps, OperationsRecord, EXEC, IsOddInt, IsEvenInt );

This defines the global variables LengthString etc. and sets them to
a special value such that when one of them is evaluated the command
"ReadLib( "abattoir" )" is executed, and then the variable is
re-evaluated. Reading this library file overwrites the values of
all these globals so that it will not be automatically read again.

In other words each library file is read once the first time it is
needed and then (unless the user forces it) never again. In practice
a large part of the library is read the first time you (for example)
construct a group, and then the remaining files trickle in by dribs
and drabs.

Secondly, could someone tell me where to look in the source code to
find the code which handles the online help system. I found a number of things
in 'system.c', but is it all localised to a single module, or does the help
system require parts from many different files.

I think it is in system.c. Certainly it was last time I looked for

The reason I am wondering about these two things is that I am thinking
about whether it might be possible to make some not-too-difficult modification
which would enable GAP to be run with the files in 'lib' 'doc', and so on, as
compressed files (to save precious disk space).

This should be possible, though I suspect that it would slow down the
GAP start-up (when most of the library is read) quite a lot. All
reading of files is done in system.c, so it should be enough to
change a few routines there to look for <name>.gz as well as <name>
and set up a gunzip process if needed. I think you just need to
look at SyFopen, SyFgets and SyFclose, but don't quote me on that.

One thing you can do is to strip comments and superfluous white
space from the library files. I once wrote a little PERL script to
do it, though I don't think I have it any more. You have to be
careful of quoted # signs, quoted \" characters and so on, but it
can be done.

I take it you have already deleted source and object files and given
thought to which of the group and character table libraries you


> < [top]