File: libform.tex

package info (click to toggle)
gap 4r4p10-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 29,224 kB
  • ctags: 7,084
  • sloc: ansic: 98,591; sh: 3,284; perl: 2,263; makefile: 467; awk: 6
file content (204 lines) | stat: -rw-r--r-- 8,769 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%W  libform.tex              GAP documentation           Alexander Hulpke
%%
%H  @(#)$Id: libform.tex,v 4.13.2.1 2004/01/27 11:37:59 stefan Exp $
%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Chapter{Library Files}

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~"ref:LoadPackage" in the Reference manual)
assumes this).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{File Types}

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

\beginitems
`.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~"ref:Completion Files" in the Reference Manual).
\enditems

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{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:
\begintt
Revision.file_suf :=
    "@(#)$Id: libform.tex,v 4.13.2.1 2004/01/27 11:37:59 stefan Exp $";
\endtt
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.
%\begintt
\)\kernttindent\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#
\)\kernttindent\#\#
\)\kernttindent\#<X>\ \ ExampleFunction(\<A>,\<B>)
\)\kernttindent\#\#
\)\kernttindent\#\#\ \ This function does nothing.
%\endtt

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~"ref: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 
\begintt
#E
\endtt
comment section that may be used to store formatting descriptions for an
editor.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{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~"ref: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.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Section{Undocumented Variables}

For several global variables in {\GAP},
no information is available via the help system 
(see Section~"tut:Help" in the Tutorial, for a quick overview of the 
help system, or Chapter~"ref: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 \Mailto{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}.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%E