DIP 1027---String Interpolation---Community Review Round 1

Nick Treleaven nick at geany.org
Mon Dec 16 14:00:36 UTC 2019

On Monday, 16 December 2019 at 13:22:45 UTC, Atila Neves wrote:
> On Monday, 16 December 2019 at 10:48:51 UTC, aliak wrote:
>> User: why can't I do this?/Why doesn't this work?
>> string s = i"$var";
>> Answer?
> import std.format: format;
> string s = format(i"$var");

That isn't an answer to the question, it's just a workaround. 
Interpolated strings could implicitly convert to strings, which 
is the most common use case in typical D code. That would not 
bloat code that doesn't need it, as Adam has shown by using an 
import inside a template.

Interpolated strings should not be designed with low-level 
concerns as the priority motivator at the cost of high level 
usability and safety.

D is supposed to be a type safe language, even std.format.format 
is not fully type safe because using string for a format string 
allows runtime errors.

Any good D interpolation proposal would support compile time 
checked format strings, even when runtime arguments are passed. D 
is supposed to be the best language for compile time stuff!

More information about the Digitalmars-d mailing list