DIP 1027--String Interpolation--Final Review Discussion Thread

Adam D. Ruppe destructionator at gmail.com
Sun Feb 2 19:40:39 UTC 2020


On Sunday, 2 February 2020 at 19:22:23 UTC, Dennis wrote:
> In all seriousness, I understand that eagerly constructing new 
> strings is a bad practice for performant code and that you want 
> to discourage it. I just think that since D is also pretty good 
> for quick scripts or fast prototyping, being able to quickly 
> type an interpolated string to evaluate to `string` would be 
> very convenient.

Yeah. Though see my last email for another point on this re 
encoding for different contexts.

And take note that with the struct proposal, it will not require 
an import. I'd implement it like:

string toString()() {
    import std.conv;
    return text(args);
}

so the import is internal to it (so you don't have to write it 
yourself), and being templated, the import is only triggered if 
the method is actually used (so you don't pay for it in cases 
like -betterC where you don't want it).

note we can also offer the toString(scope delegate() sink) 
version for working with those parts of the library that are 
allocation averse too.


So many of these problems are already solved in D library 
techniques!


More information about the Digitalmars-d mailing list