Ticket #1284 (assigned todo)
Integer PMC missing math methods
Reported by: | coke | Owned by: | whiteknight |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | core | Version: | master |
Severity: | medium | Keywords: | |
Cc: | Language: | ||
Patch status: | Platform: | all |
Description
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