After a method has been selected and called,
this method may recognize that it cannot compute the desired result,
and give up by calling TryNextMethod().
In effect, the execution of the method is terminated,
and the method selection calls the next method that is applicable w.r.t.
the original arguments.
In other words, the applicable method is called that is subsequent to the
one that called TryNextMethod,
according to decreasing rank of the methods.
For example, since every finite group of odd order is solvable,
one may install a method for the property IsSolvableGroup that checks
whether the size of the argument is an odd integer,
returns true if so,
and gives up otherwise.
Care is needed if a partial method might modify the type of one of its
arguments, for example by computing an attribute or property. If this happens,
and the type has really changed, then the method should not exit using
TryNextMethod() but should call the operation again, as the new information
in the type may cause some methods previously judged inapplicable to be
applicable. For example, if the above method for IsSolvableGroup actually
computes the size, (rather than just examining a stored size), then it must
take care to check whether the type of the group has changed.
[Top] [Previous] [Up] [Next] [Index]
GAP 4 manual