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

Walter Bright newshound2 at digitalmars.com
Wed Feb 5 09:08:16 UTC 2020


On 2/4/2020 10:48 PM, Arine wrote:
>      float a;
>      double b;
>      real c;
>      int d;
> 
>      printf(i"$a $b $c $d");
> 
> So the above translates to:
> 
>      printf("%s %s %s %s", a, b, c, d);

That's right.


> Because of 1, I have to *COMPLETELY* disagree. There's no way in hell this DIP 
> should move forward without a checker if you plan with functionality of 1. 
> You're going to force people to label specifiers themselves, when the compiler 
> knows full well what type they are passing? That's just rediculous. No other 
> language does this. The whole point is to keep it clean where you can. A float 
> should have a %f not a %s inserted into the format.

The compiler actually cannot know that it is a printf format. For example, dmd 
is full of printf-like functions that are not called printf.


> You are lowering it for one minor use case where it is convenient , and then 
> causing ugly behavior everywhere else. Not to mention it doesn't even do it 
> properly, cause if you want to use a float you have to manually put %f yourself.

If you don't care for printf, that's why D has writef, where %s means "just make 
it work".


 > This is what happens when someone that doesn't understand a feature and what
 > benefits it brings tries to implement it. I'm sorry if that's harsh but it's
 > the truth.

Berating other people in the forum is not permitted. Professional demeanor is 
expected.


More information about the Digitalmars-d mailing list