Ticket #1284 (assigned todo)

Opened 12 years ago

Last modified 11 years ago

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


IMO, this code:

.sub main
  $P1 = box 1.0
  $N1 = $P1.'exp'()
  say $N1
  $P1 = box 1
  $N1 = $P1.'exp'()
  say $N1

should print 2.71828182845905 2.71828182845905

... but it dies with:

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

Change History

Changed 11 years ago by bacek

+1 to remove methods. Just to reduce code size sake.

-- Bacek.

Changed 11 years ago by cotto

  • type changed from RFC to todo

I agree with bacek. Specialized math code belongs in a separate project. The solution to this is to remove the methods from Float. They can be dug up later if needed.

Changed 11 years ago by whiteknight

  • status changed from new to assigned
  • owner set to whiteknight

If that's the case, we should put in a deprecation notice for those things now. I'm happy to move these methods and functionalities into a new project, probably the same one where the Complex PMC is going to move.

Changed 11 years ago by jkeenan

  • component changed from none to core

Can we get an update on the status of this ticket? (Sounds like we're thinking of deprecating several things, not just those mentioned in this ticket.)

Thank you very much.


Changed 11 years ago by whiteknight

  • platform set to all
  • version changed from trunk to master

A deprecation notice for the removal of these methods was never added (as far as I can see). We need to do that first before we can talk about removing things.

We can bring it up at #ps if people think this needs more discussion. I probably won't be at #ps this week so somebody else is going to have to raise the issue.

Changed 11 years ago by dukeleto

Are we seriously calling exp "specialized math code" ? I beg to differ, greatly. Just about every language I have ever seen comes with exponentiation. Do we really want end users to deal with including and depending on some external library that implement 4000 math methods they don't care about, just to be able to exponentiate? Sounds horrific.

I am not against other, less common, math methods being removed, but not exp or log. I am also +1 to adding exp/log to Integer PMCs.

This ticket is not closable in its current state. I am of the opinion that it should be rejected and more specific tickets created.

Note: See TracTickets for help on using tickets.