DIP 1027---String Interpolation---Community Review Round 1
Patrick.Schluter at bbox.fr
Mon Dec 16 11:08:00 UTC 2019
On Monday, 16 December 2019 at 10:48:51 UTC, aliak wrote:
> On Monday, 16 December 2019 at 01:35:51 UTC, Walter Bright
>> On 12/15/2019 2:17 AM, Aliak wrote:
>>> To use it people will need to understand how to use d tuples
>>> as well.
>> No, they don't.
> User: why can't I do this?/Why doesn't this work?
> string s = i"$var";
string s = ("%s",var);
is a syntax error. Even a beginning programmer can understand
that an interpolated string cannot be a pure simple string as it
contains symbols and expressions that are language construct not
part of the string literal, i.e. that the compiler has to perform
some transformations to substitute these language symbols into a
Interpolated strings, in any language, are not string literals.
Each language resolves this fact in different manners and at
different times. Interpreted languages do it at runtime
(obviously), java like languages chose to do it at runtime. In a
language like D, which prefers resolving what is resolvable at
compile time, it would be loathed if it interpolation was
resolved at runtime (remember how long people were bitching about
runtime only format strings?)
Resolving interpolation at compile time is imho incompatible with
handling them as regular strings.
The question is then do we want CT or RT interpolated strings. RT
interpolated strings can still be provided by a library.
More information about the Digitalmars-d