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
constant folding should be signaled with @inline, not final #7542
Comments
Imported From: https://issues.scala-lang.org/browse/SI-7542?orig=1 |
@retronym said: Here's one more visible difference to the the current scheme that I noticed a while back in scala> object O { final val YES = 1; YES: Byte }
scala> object O { @inline val YES = 1; YES: Byte }
<console>:7: error: type mismatch;
found : Int
required: Byte
object O { @inline val YES = 1; YES: Byte }
^ ^ |
@soc said: This could also improve incremental compile time, because less classes need to be recompiled if a constant changes. |
@soc said: |
@paulp said: |
@SethTisue said (edited on Aug 26, 2016 6:43:19 PM UTC): |
I think this is now out of scope to change in Scala 2. Scala 3 has |
The conclusion in 2013 was that it's easier to just rewrite Scala from scratch to support |
The semantics of constant folding are a source of endless confusion, ignorance, and eventually consternation.
And even if you know all the rules, you have a good chance of being out of luck:
Is it reasonable to expect people to intuit that s5 has only a reference to string constant "abcdef", but s4 calls s2? I don't think so.
There is an obvious solution, which will also be the right kind of obvious to the scala programmer. If you want a constant inlined, mark it @inline.
We can do this immediately, keeping the final semantics as well for as long as desired, but ideally deprecating it in favor of @inline now.
The text was updated successfully, but these errors were encountered: