dart-sdk/docs/language
Lasse R.H. Nielsen 0808d29b4e Update spec of potentially constant and compile-time constant expressions.
The existing specification was underspecifying potentially constant expressions,
effectively relying on evaluation to determine whether an expression was
potentially constant.

This change specifies potentially constant recursively using only the syntax
of the expressions.

Adds short-circuting to `?:`, `??`, `||` and `&&` expressions,
so for `String x`, the expression `x != null && x.length > 0`
is compile-time constant.
The original specification requred evaluation of the latter half
even when `x` is null. We can now avoid this because we can require that the
unused expression is a potentially constant expression without having to
check if it, or any part of it, is a compile-time constant expression.

Allows `x == null` and `x != null` as compile-time constant expression
independently of the type of `x`.

Allows `e as T` as a compile-time constant expression. Types are more
important in Dart 2, so you need a way to adjust typing in some cases,
even in compile-time constant expressions.

Change-Id: I02bf0b77013c3b3ced8cd46334db378787cc2d57
Reviewed-on: https://dart-review.googlesource.com/36220
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2018-09-26 14:17:39 +00:00
..
informal Fix typo in int-to-double.md 2018-09-12 12:47:15 +00:00
.gitignore Clarify that global/local/static functions can also be closurized 2018-05-04 13:57:15 +00:00
Dart.g Introduced support for metadata on enum values 2018-05-09 08:27:08 +00:00
dart.sty Adjusted spec to use package syntax, thus eliminating bnf.sty 2018-09-20 11:12:14 +00:00
dartLangSpec.tex Update spec of potentially constant and compile-time constant expressions. 2018-09-26 14:17:39 +00:00
Makefile Specify behavior of e?.v++ and e?.v-- 2015-06-11 15:01:06 -07:00