Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make scala.BigDecimal extend java.math.BigDecimal #8721

Closed
scabug opened this issue Jul 14, 2014 · 5 comments
Closed

Make scala.BigDecimal extend java.math.BigDecimal #8721

scabug opened this issue Jul 14, 2014 · 5 comments

Comments

@scabug
Copy link

scabug commented Jul 14, 2014

Since java.math.BigDecimal is not final, it would save an extra object instance if scala.BigDecimal extended j.m.BD instead of wrapping it.

It would also make s.BD => j.m.BD conversion needless.

Same applies to BigInteger/BigInt

@scabug
Copy link
Author

scabug commented Jul 14, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8721?orig=1
Reporter: @nilskp

@scabug
Copy link
Author

scabug commented Mar 31, 2015

@Ichoran said:
Unfortunately, the only way to change some of the awkward semantics of Java's BigDecimal (by carrying along a MathContext) is to wrap it rather than extending it, unless we override every method that returns a Java BigDecimal.

So inheritance doesn't really work--never really does, without a more advanced type system, when you need to return something of the same type as yourself.

@scabug scabug closed this as completed Mar 31, 2015
@scabug
Copy link
Author

scabug commented Apr 8, 2015

@nilskp said:

unless we override every method that returns a Java BigDecimal

If that's the only problem, is that so bad?

@scabug
Copy link
Author

scabug commented Apr 8, 2015

@Ichoran said:
@nilskp Yes, it is so bad. It matters which BigDecimal you're using, and it will be easy to get even more confused than you already are (e.g. use external library and not realize you need to rewrap), and it's a maintenance headache to catch everything (e.g. if Java ever adds a method to BigDecimal we have to notice and add it also and re-implement that function for earlier versions of Java so we're compatible with more than just the latest).

@scabug
Copy link
Author

scabug commented Apr 8, 2015

@nilskp said:
Perhaps, not sure. Anyway, it's obviously not that important.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants