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

nullptr null at p.tr
Thu Feb 6 13:02:18 UTC 2020


On Thursday, 6 February 2020 at 07:00:33 UTC, Walter Bright wrote:
> For one thing, it becomes part of the language specification. 
> It has to be documented and taught. It turns a simple feature 
> into a complex one. Having language semantics controlled by a 
> hidden template is not in any other part of D. It implies that 
> the behavior of interpolated strings is not predictable. 
> Template instantiations are a LOT slower than direct 
> implementation. Lots of interpolated strings means lots of 
> template instantiations.
>
> Yes, it's also significantly more code to implement, and there 
> has to be error recovery for when the template can't be found, 
> and checks for a rogue template.
>
> All that has to be weighed against the benefit. Implementing 
> something just because it is feasible and ticks a box is not a 
> sufficient reason to do it. D must have smallish features that 
> are widely useful, not be a large collection of trivia.

If you aren't going to allow this feature to have enough 
complexity to be worthwhile then I'd suggest you retract this DIP 
entirely. I work primarily in C# and I use interpolated strings 
all over the place because they Just Work and make string 
manipulation much easier to read. The implementation you've 
suggested here is the bare minimium to make string interpolation 
work in some cases for some things without any kind of 
protections for the user against accidentally (and silently!) 
breaking their code, and I would much rather not have string 
interpolation in D at all if the alternative is what is described 
in this DIP.


More information about the Digitalmars-d mailing list