What parts of the design are still undecided? Design meetings
The current + operator for string concatnation can combine strings in a similar manner to the current proposal. Most use cases can be largely replicated through the alternatives below. As these strings are fully evaluated at compile time, the valuable automatic formatting features of interpolated strings are less neccesary. This proposal adds additional complexity to the compiler in exchange for broader applicability of interpolated strings.
This is true even if the expression is a sub-expression of a larger expression that contains non-constant constructs. Whenever an expression fulfills the requirements listed above, the expression is evaluated at compile-time. The initialization of str is an error because an implicit reference conversion from a non-null value is required. The initialization of i is an error because a boxing conversion is required. For example: class CĬonst object i = 5 // error: boxing conversion not permittedĬonst object str = "hello" // error: implicit reference conversion Other conversions including boxing, unboxing and implicit reference conversions of non-null values are not permitted in constant expressions. Implicit and explicit reference conversions, provided that the source of the conversions is a constant expression that evaluates to the null value.The following conversions are permitted in constant expressions: However, there have been many community requests to make the following also legal: public class CĬonst string S3 = $", provided that all components are constant expressions of type string and all interpolated components lack alignment and format specifiers.
Flex type was not found or was not a compile time constant code#
The following code is already legal: public class CĬonst string S2 = "Hello" + " " + "World" Ĭonst string S3 = S1 + " Kevin, welcome to the team!" Enables constants to be generated from interpolated strings of type string constant.