kernel: don't use ProdIntObj as ProdFunc; use PowObjInt less #2198
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We used to install ProdIntObj and PowObjInt for a large variety of TNUMs,
including precords, functions, strings etc., where they never made sense:
And for those TNUMs where it did make sense (e.g. T_RAT), often later modules
would install more specialized functions anyway. For ProdIntObj, this meant
that the only sensible place it was used was for T_MACFLOAT. This PR removes
even that, though, since it was only used for
int * float
, but not forfloat * int
, which resulted in the two behaving differently:Hence, we stop using ProdIntObj as kernel level ProdFunc completely, even for
machine floats, and instead,rely on library functions for multiplying integers
and floats.
Note that ProdIntObj can still be invoked from the library via PROD_INT_OBJ,
and this is used to install default multiplication functions for integers with
IsNearAdditiveElementWithInverse elements (and these method installations are
also provided symmetrically, i.e. intobj as well as objint). While this is
very slightly slower, it is at least guaranteed to be symmetric and
mathematically well-defined.
For PowObjInt, the asymmetry is natural, so less of a problem. Also, it turns
out that it is actually used in a few more cases, e.g. to power
transformations and partial permutations. Still, doing f^1 for a function or
'x'^1 or true^1 are all surprising. To resolve this, we restrict for which
TNUMs we install PowObjInt as PowFunc substantially: We don't use it on all
constant TNUMs anymore, but rather only on those were multiplication by an
integer makes some sense, using the new TNUM range FIRST_MULT_TNUM till
LAST_MULT_TNUM. We also don't install it for records anymore, and also not for
blists and strings. It is kept for ranges and other plists, as there it has a
chance of a well-defined behavior (if the list describes a vector,
possibly a matrix).