Feedback Thread: DIP 1036--Formatted String Tuple Literals--Community Review Round 1

Walter Bright newshound2 at
Sun Sep 13 03:23:27 UTC 2020

Under "Wrong-use in unrelated function" it says:

     Window createWindow(string title, int width = 0, int height = 0);

A user has some code that calls it like so:

     import std.conv;
     auto window = createWindow("Process debugger " ~ to!string(pid));

A new version of the compiler is released and the user, eager to try D's new 
string interpolation feature, rewrites that code as would be common in many 
other languages:

     auto window = createWindow(i"Process debugger $pid");

This would compile without error, but would not do what the user intended.

This is indeed correct, but I take issue with "as would be common in many other 
languages". Because of D's close relationship with C, it would be a fair 
statement to compare with C. But C doesn't have string interpolation. It is 
impossible to constrain D based on what people expect from "many other languages".

D should do what is best for D, not what is best for C#, Forth, or Haskell. It 
is not unreasonable to expect people to at least glance at the instructions 
before assuming D is just like Language X. If they don't (and we're all guilty 
of that) then they get to debug it, like first noticing that the window title 
reads "Process debugger %s", which is not disastrous.

#DIP1038 needs a much better rationale as to why it should be preferred over 

(On a related note, I propose that default arguments are an overused feature, 
and should raise an eyebrow when used. There are many other inadvertent problems 
one can run into with careless use of it.)

More information about the Digitalmars-d mailing list