[Top] [Up] [Previous] [Next] [Index]

# 3 Library Files

### Sections

1. File Types
2. File Structure
3. Finding Implementations in the Library
4. Undocumented Variables

This chapter describes some of the conventions used in the GAP library files. These conventions are intended as a help on how to read library files and how to find information in them. So everybody is recommended to follow these conventions, although they do not prescribe a compulsory programming style -- GAP itself will not bother with the formatting of files.

Filenames have traditionally GAP adhered to the 8+3 convention (to make it possible to use the same filenames even on a MS-DOS file system) and been in lower case (systems that do not recognize lower case in file names will convert them automatically to upper case). It is no longer so important to adhere to these conventions, but at the very least filenames should adhere to a 16+5 convention, and be distinct even after identifying upper and lower case. Directory names of packages, however, must be in lower case (the `LoadPackage` command (see LoadPackage in the Reference manual) assumes this).

## 3.1 File Types

The GAP library consists of the following types of files, distinguished by their suffixes:

`.g`
  Files which contain parts of the ``inner workings'' of GAP. These files usually do not contain mathematical functionality, except for providing links to kernel functions.

`.gd`
  Declaration files. These files contain declarations of all categories, attributes, operations, and global functions. These files also contain the operation definitions in comments.

`.gi`
  Implementation files. These files contain all installations of methods and global functions. Usually declarations of representations are also considered to be part of the implementation and are therefore found in the `.gi` files.

  As a rule of thumb, all `.gd` files are read in before the `.gi` files are read. Therefore a `.gi` file usually may use any operation or global function (it has been declared before), and no care has to be taken towards the order in which the `.gi` files are read.

`.co`
  Completion files. They are used only to speed up loading (see Completion Files in the Reference Manual).

## 3.2 File Structure

Every file starts with a header that lists the filename, copyright, a short description of the file contents and the original authors of this file.

This is followed by a revision entry:

    Revision.file_suf :=
        "@(#)$Id: libform.tex,v 4.13.2.1 2004/01/27 11:37:59 stefan Exp $";

where `file.suf` is the file name. The revision control system used for the development will automatically append text to the string ```Id:` '' which indicates the version number. The reason for these revision entries is to give the possibility to check from within GAP for revision numbers of a file. (Do not mistake these revision numbers for the version number of GAP itself.)

Global comments usually are indented by two hash marks and two blanks. If a section of such a comment is introduced by a line containing a hash mark and a number it will be used for the manual (stripped of the hash marks and leading two blanks; see Section Using buildman.pe).

Every declaration or method or function installation which is not only of local scope is introduced by a function header of the following type.
`#############################################################################`
`##`
`#`X `ExampleFunction(<A>,<B>)`
`##`
`## This function does nothing.`

The X in the example is one of the letters: `F`, `A`, `P`, `O`, `C`, `R` or `V`, and has the same meaning as at the end of a declaration line in the Reference Manual (see Manual Conventions in the Reference Manual); it indicates whether the object declared will be a function, attribute, property, operation, category, representation or variable, respectively. Additionally `M` is used in `.gi` files for method installations. The line then gives a sample usage of the function. This is followed by a comment which describes the identifier. This description will automatically be extracted to build the Reference Manual source, if there is a `\Declaration` line in some `.msk` file together with an appropriate configuration file (see Section Using buildman.pe).

Indentation in functions and the use of decorative spaces in the code are left to the decision of the authors of each file.

The file ends with an

    #E

comment section that may be used to store formatting descriptions for an editor.

## 3.3 Finding Implementations in the Library

There is no general browsing tool that would point you to the place in the library where a certain method or global function is installed. However the following remarks might be of help:

You can use `ApplicableMethod` (see ApplicableMethod in the reference manual) to get the function which implements a method for specific arguments. Setting its print level higher will also give you the installation string for this method.

To find the occurrence of functions and methods in the library, one can use the `grep` tool under UNIX. To find a function, search for the function name in the `.gd` files (as it is declared only once, only one file will show up), the function installation is likely to occur in the corresponding `.gi` file.

To find a method search for `Method(` (this catches `InstallMethod` and `InstallOtherMethod`) and the installation string or the operation name.

## 3.4 Undocumented Variables

For several global variables in GAP, no information is available via the help system (see Section Help in the Tutorial, for a quick overview of the help system, or Chapter The Help System in the reference manual, for details). There are various reasons for ``hiding'' a variable from the user; namely, the variable may be regarded as of minor importance (for example, it may be a function called by documented GAP functions that first compute many input parameters for the undocumented function), or it belongs to a part of GAP that is still experimental in the sense that the meaning of the variable has not yet been fixed or even that it is not clear whether the variable will vanish in a more developed version.

As a consequence, it is dangerous to use undocumented variables because they are not guaranteed to exist or to behave the same in future versions of GAP.

Conversely, for documented variables, the definitions in the GAP manual can be relied on for future GAP versions (unless they turn out to be erroneous); if the GAP developers find that some piece of minor, but documented functionality is an insurmountable obstacle to important developments, they may make the smallest possible incompatible change to the functionality at the time of a major release. However, in any such case it will be announced clearly in the GAP Forum what has been changed and why.

So on the one hand, the developers of GAP want to keep the freedom of changing undocumented GAP code. On the other hand, users may be interested in using undocumented variables.

In this case, whenever you write GAP code involving undocumented variables, and want to make sure that this code will work in future versions of GAP, you may ask at support@gap-system.org for documentation about the variables in question. The GAP developers then decide whether these variables shall be documented or not, and if yes, what the definitions shall be.

In the former case, the new documentation is added to the GAP manual, this means that from then on, this definition is protected against changes.

In the latter case (which may occur for example if the variables in question are still experimental), you may add the current values of these variables to your private code if you want to be sure that nothing will be broken later due to changes in GAP.

[Top] [Up] [Previous] [Next] [Index]

GAP 4 manual
May 2005