DIP 1027---String Interpolation---Community Review Round 1
aliak
something at something.com
Mon Dec 16 11:38:34 UTC 2019
On Monday, 16 December 2019 at 11:08:00 UTC, Patrick Schluter
wrote:
> On Monday, 16 December 2019 at 10:48:51 UTC, aliak wrote:
>> [...]
>
> because
>
> string s = ("%s",var);
>
> is a syntax error.
Exactly. And then explain why. And what is that thing on the
right. And why is string assignment not working on an
interpolated _string_?
> 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
> value.
> Interpolated strings, in any language, are not string literals.
In any language, they can be assigned to strings.
> 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.
See Adam's previous posts on his approach.
More information about the Digitalmars-d
mailing list