petdance/scratch — Issue #198: Integer PMC missing math methods
Author: petdance
Created: 2011-11-01 05:41:31+00:00
State: open
Labels: core, Pri-normal, Sev-medium, todo

IMO, this code:
{{{
.sub main
$P1 = box 1.0
$N1 = $P1.'exp'()
say $N1
$P1 = box 1
$N1 = $P1.'exp'()
say $N1
.end
}}}

should print
2.71828182845905
2.71828182845905

... but it dies with:

{{{
2.71828182845905
Method 'exp' not found for invocant of class 'Integer'
}}}

Clearly, exp isn't defined on Integer, but IMO, all the math methods defined on Float should be defined on Integer. (otherwise, given an arbitrary numeric PMC, we have to jump through hoops.

(Alternatively, we can remove these methods from the Float PMC and rely on the opcodes.)

This becomes even more confusing when you take in the morphing of the core types - a PMC that was a Float can morph into an Integer which is then unable to invoke the various methods.

This issue was originally opened as http://rt.perl.org/rt3/Ticket/Display.html?id=38896

Originally http://trac.parrot.org/parrot/ticket/1284