Already in GAP 3 there were several functions that were applicable
to many different kinds of objects, for example Size could be
applied to any domain, and the binary infix multiplication * could
be used to multiply two matrices, an integer with a row vector, or a
permutation with a permutation group. This was implemented as
follows. Functions like Size and * tried to find out what
situation was described by its arguments, and then it called a more
specific function to compute the desired information. These more
specific functions, let us call them methods as they are also called
in GAP 4, were stored in so-called operations records of the
arguments.
For example, every domain in GAP 3 was represented as a record, and
the operations record was stored in the record component operations.
If Size was called for the domain then the method to compute the
size of the domain was found as value of the Size component of the
operations record.
This was fine for functions taking only one argument, and in principle it is possible that for those functions an object stored an optimal method in its operations record. But in the case of more arguments this is not possible. In a multiplication of two objects in GAP 3, one had to choose between the methods stored in the operations records of the arguments, and if for example the method stored for the left operand was called, this method had to handle all possible right operands.
So operations records turned out to be not flexible enough. In GAP 4, operations records are not supported (see Compatibility Mode for a possibility to use your GAP 3 code that utilizes operations records, at least to some extent). A detailed description of the new mechanism to select methods can be found in Chapter Method Selection in ``Programming in GAP''.
An important point is that the new mechanism allows GAP to take the relation between arguments into account. So it is possible (and recommended) to install different methods for different relations between the arguments. Note that such methods need not do the extensive argument checking that was necessary in GAP 3, because most of the checks are done already by the method selection mechanism.
[Top] [Previous] [Up] [Next] [Index]
GAP 4 manual