As mentioned above the method selection will not test unknown properties. In situations, in which algorithms are only known (or implemented) under certain conditions, however such a test might be actually desired.
One way to achieve this would be to install the method under weaker
conditions and explicitly test the properties first, exiting via
TryNextMethod if some of them are not fulfilled.
A problem of this approach however is that such methods then automatically
are ranked lower and that the code does not look nice.
A much better way is to use redispatching: Before deciding that no method has been found one tests these properties and if they turn out to be true the method selection is started anew (and will then find a method).
This can be achieved via the following function:
RedispatchOnCondition( oper, fampred, reqs, cond, val )
This function installs a method for the operation oper under the
conditions fampred and reqs which has absolute value val;
that is, the value of the filters reqs is disregarded.
cond is a list of filters.
If not all the values of properties involved in these filters are already
known for actual arguments of the method,
they are explicitly tested and if they are fulfilled and stored after
this test, the operation is dispatched again.
Otherwise the method exits with TryNextMethod.
This can be used to enforce tests like IsFinite in situations when all
existing methods require this property.
The list cond may have unbound entries in which case the corresponding
argument is ignored for further tests.
[Top] [Previous] [Up] [Next] [Index]
GAP 4 manual