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

Meta jared771 at gmail.com
Wed Dec 11 19:15:18 UTC 2019


On Wednesday, 11 December 2019 at 18:58:46 UTC, Robert Schadek 
wrote:
> I'm not really sure if the balance of added complexity vs. 
> payoff is in favor of payoff.
> They only time I felt the need for such a feature was when I 
> had very long DelimitedStrings.
> And those long strings where a constant source bugs, so I split 
> them up and the field need for interpolated strings want away 
> with the bugs.
>
> Not being able to use * will stop me using this feature in many 
> places.
>
>
> The rationale about "missing arguments, wrong format 
> specifier,... " Is a mute point IMO. format!"%d"(13.37) does 
> the same thing already without any language change.
> I thought the idea was not to introduce language changes if a 
> library solution can do most of it already.
> I find that the readability argument is highly subjective.
> The first part of the rationale is, IHO,
> already pointing to the solution. Short strings are easy to 
> manage.
> So let's promote short strings in
> combination with format!"%s" and
> output ranges.
>
> How will this feature work at CT.
> Format doesn't even work completely at CT.
>
> I know this goes a bit off topic,
> but IMO this is a feature that is wanted,
> because other languages have it.
> And we want to say we have it too.
> I think it's a lot nicer to say, we don't need this, because 
> our templates
> can already do that.
>
> TL/DR: not a fan

It can *almost* already be done with templates:
https://github.com/Abscissa/scriptlike#string-interpolation

The main sticking point is that you have to write 
mixin(interp!"....") so the symbols will be looked up in the 
proper scope. Unfortunately, that also means that the above 
syntax is the best a library solution can do, currently.


More information about the Digitalmars-d mailing list