Global variables in the GAP library are usually read-only in order to avoid that they are overwritten by chance.
BindGlobal( name, val ) F
sets the global variable named by the string name to the value val, and makes it read-only. An error is given if the global variable corresponding to name already had a value bound.
The different types of filters (see Sections Creating Categories,
Creating Representations, Creating Attributes and Properties,
Creating Other Filters) that are used in the GAP library are
assigned by the following functions which make the variables automatically
read-only.
The only other difference between NewSomething and
DeclareSomething is that DeclareAttribute and DeclareProperty
also bind read-only global variables with names Hasname and Setname
for the tester and setter of the attribute,
see Section Setter and Tester for Attributes in the Reference Manual.
For the meaning of the arguments of DeclareSomething,
see NewAttribute, NewCategory, NewFilter, NewProperty,
and NewOperation.
DeclareAttribute( name, filt[, "mutable"][, rank] ) F
DeclareCategory( name, super ) F
DeclareFilter( name, rank ) F
DeclareProperty( name, filt[, rank] ) F
Also operations and other global functions used in the GAP library are assigned to read-only variables, with the following functions.
DeclareOperation( name, args-filts ) F
DeclareGlobalFunction( name ) F
GAP functions that are not operations and that are intended to be
called by users should be notified to GAP in the declaration part
of the respective package
(see Section Declaration and Implementation Part)
via DeclareGlobalFunction, which returns a function that serves as a
place holder for the function that will be installed later,
and that will print an error message if it is called.
A global function declared with DeclareGlobalFunction can be given its
value func via
InstallGlobalFunction( gvar, func ) F
where gvar is the variable named with the name argument of the call
to DeclareGlobalFunction.
(Note that func must be a function which has not been declared as a
GlobalFunction itself. Otherwise completion files
(see Completion Files in the reference manual) get confused!)
For global variables that are not functions,
instead of using BindGlobal one can also declare the variable with
DeclareGlobalVariable( name[, description] ) F
which creates a new global variable named by the string name.
If the second argument description is entered then this must be
a string that describes the meaning of the global variable.
DeclareGlobalVariable shall be used in the declaration part of the
respective package (see Declaration and Implementation Part),
values can then be assigned to the new variable with InstallValue or
InstallFlushableValue, in the implementation part
(again, see Declaration and Implementation Part).
InstallValue( gvar, value ) F
InstallFlushableValue( gvar, value ) F
InstallValue assigns the value value to the global variable gvar.
InstallFlushableValue does the same but additionally provides that
each call of FlushCaches (see FlushCaches)
will assign a structural copy of value to gvar.
InstallValue does not work if value is an ``immediate object''
(i.e., an internally represented small integer or finite field element).
Furthermore, InstallFlushableValue works only if value is a list.
(Note that InstallFlushableValue makes sense only for mutable
global variables.)
FlushCaches() O
FlushCaches resets the value of each global variable that has
been declared with DeclareGlobalVariable and for which the initial
value has been set with InstallFlushableValue to this initial value.
FlushCaches should be used only for debugging purposes,
since the involved global variables include for example lists that store
finite fields and cyclotomic fields used in the current GAP session,
in order to avoid that these fields are constructed anew in each call
to GF and CF (see GaloisField and CyclotomicField
in the Reference Manual).
[Top] [Previous] [Up] [Next] [Index]
GAP 4 manual