Add string interpolation syntax that only accepts values of type String.
#5553
Replies: 2 comments 1 reply
-
|
What are the motivations and use cases for this language change? What would make it different from the existing syntax for building up strings from other strings? |
Beta Was this translation helpful? Give feedback.
-
|
In short: Still predictable type behavior (no hidden conversions) But
Long: The primary motivation is readability and reduction of cognitive overhead. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Add string interpolation syntax that only accepts values of type
String.Example:
"Hello {name}!"This should be equivalent to concatenation and must not perform implicit type conversions. Non-string values should result in a compile-time error.
This keeps interpolation ergonomic while preserving explicitness and type safety.
Alternatively, a syntax like
"Hello <>name<>"could be considered for backward compatibility, avoiding{}-style interpolation while still improving readability over manual concatenation.Beta Was this translation helpful? Give feedback.
All reactions