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

Patrick Schluter Patrick.Schluter at bbox.fr
Wed Dec 11 19:34:01 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.

Disagree. This proposition strikes exactly the right balance 
imho. The other syntaxes proposes that lean more on Java/C# I 
would agree with you. This proposition though is just a simple 
composition of the existing C heritage and the availaible D 
feature (tuple).

> 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.

So you complexified your code because of a restriction of the 
language.

>
> 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

MOOT not mute

> 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.

It is but it is also true that from more than 4 parameters in a 
format string it gets more and more noisy.

> 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.

It's a problem with format and is perpendicular to this DIP, i.e. 
if this DIP is adopted or not, it will not change anything to the 
issues of format.

>
> 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.

May be sometimes it is good to look why certain features are 
spreading like wildfire. C format specifiers were a regression 
compared to what was available at that time (in Pascal or even 
Cobol), but as C had so much other things to it, people tended to 
accept the strange and ugly printf formatting, but it's clear 
that i was universally loathed. That's why C++ tried this worse 
shift syntax and other languages tried other solutions.
It is not because we in the end managed to get used to the 
outdated and dangerous printf format that it is good in the first 
place.
This DIP is simple enough that it is a good candidate imho to be 
tried.

> I think it's a lot nicer to say, we don't need this, because 
> our templates
> can already do that.
>





More information about the Digitalmars-d mailing list