This page is no longer maintained — Please continue to the home page at www.scala-lang.org

package object + backward compat

1 reply
extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.

Now that there are package objects and scala.math, the contents of
scala.Math belong in that package object. However I don't see a direct
way to do that and still have scala.Math working for backward
compatibility -- can't say "val Math = scala.math" like you would if it
were moving from regular object to regular object.

The best I could do was to move the whole contents into a trait, then
have object scala.Math and package object scala.math each extend that
trait. This works, but is there a better way? And if there isn't,
should I check that in?

odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: package object + backward compat

The question is, should scala.Math be deprecated? If yes I believe we
can just leave it as it is + the @deprecated tags. Code duplication is
no issue in that case, because nobody should touch the deprecated Math
object anyway. If no, then having a common class (not trait, class is
faster) inherited by both scala.Math and scala.math is the best
solution I can see. But I'd rather deprecate it, really.

Cheers

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland