The current Integer PMC doesn't yet follow the results of these threads.
Basic behavior of that type is Perl6 or Python semantics, which is: it's
basically an arbitrary precision integer, like Python's int/long type
after merging. To achieve this functionality it silently morphs results
to a Big type capable of doing the arbitrary precision.
The summary in [1] also mentions type coercion:
10) The destination PMC is responsible for final conversion of the
inbound value
E.g. when we have
MMD add(PyInt + PyInt)
a) no overflow: VTABLE_set_integer_native(interp, dest, the_sum)
the set_integer_native vtable is responsibe to convert the C<dest> PMC
into a PyInt. For Perl types it'll be PerlInt. And base PMCs use
Integer. Following strictly this scheme does allow the inheritance of
all common functionality.
b) overflow:
if (self == dest) {
VTABLE_set_bignum(interp, self, self.intval)
// redispatch
}
else {
VTABLE_set_bignum(interp, dest, self.intval)
temp = new dest.type
VTABLE_set_bignum(interp, temp, self.intval)
// redispatch
or a similar scheme.
Float and String needs the same refactoring, but that's simpler.
To use that functionality we need a better notion for multiple
inheritance inside PMCs.
PerlInt isa (PerlAny, Integer)
PyInt isa (PyObject, Integer)
Comments?
leo