Skip to content

Document meaning of constant expressions #4527

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

Merged
merged 2 commits into from
May 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions docs/docs/reference/inline.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ inlined at the point of use. Example:
The `Config` object contains a definition of an `inline` value
`logging`. This means that `logging` is treated as a constant value,
equivalent to its right-hand side `false`. The right-hand side of such
an inline val must itself be a constant expression. Used in this way,
an inline val must itself be a [constant
expression](#the-definition-of-constant-expression). Used in this way,
`inline` is equivalent to Java and Scala 2's `final`. `final` meaning
"constant" is still supported in Dotty, but will be phased out.

Expand Down Expand Up @@ -124,11 +125,15 @@ it in backticks, i.e.

@`inline` def ...

### The definition of constant expression

Right-hand sides of inline values and of arguments for inline parameters
must be constant expressions in the sense defined by the [SLS §
6.24](https://www.scala-lang.org/files/archive/spec/2.12/06-expressions.html#constant-expressions),
including "platform-specific" extensions such as constant folding of
pure numeric computations.

### Reference

For more info, see [PR #1492](https://github.com/lampepfl/dotty/pull/1492) and
[Scala SIP 28](http://docs.scala-lang.org/sips/pending/inline-meta.html)



[Scala SIP 28](http://docs.scala-lang.org/sips/pending/inline-meta.html).