prefer()
import { prefer } from "@fed1/jsos";
A JSFunction
that allows you to specify that a multimethod should prefer
one signature over another. This is useful in cases where a multimethod has
multiple methods with the same score.
Please note that this does not prefer one method over another method. It prefers a set of comparators to another set of comparators.
It doesn't matter whether or not any methods with such signatures actually exists for the multimethod. But if there are any such methods, this preference will determine which one of the methods is preferred when both have the same score for a given set of arguments.
Usage
prefer(multimethod, preferred, notPreferred)
Parameters
# | Parameter | Required? | Type | Default |
---|---|---|---|---|
1 | multimethod | yes | TGeneric | |
2 | preferred | yes | JSArray | |
3 | notPreferred | yes | JSArray |
1. multimethod
The multimethod for which a preference shall be registered.
2. preferred
An array of comparators to the multimethod that should be preferred.
3. notPreferred
An array of comparators to the multimethod that shall not be preferred.
Return value
A JSBoolean
indicating whether or not the preference was successfully
registered.
Version History
Feature | Since version |
---|---|
prefer() | 1.0 |
See also
- API: unprefer()