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

Paul Backus snarwin at gmail.com
Thu Sep 10 20:50:24 UTC 2020

On Thursday, 10 September 2020 at 18:45:02 UTC, Steven 
Schveighoffer wrote:
> I disagree completely. This DIP is on the right track. And I'm 
> happy to "waste time" if it means it gets a fair shake at 
> inclusion. It costs me nothing to have it be judged.

Fair enough--that's your judgement call to make.

>> I understand perfectly. My criticism of DIP 1036 is not that 
>> you have failed at what you set out to do, but that you have 
>> set out to do the wrong thing to begin with.
> How about you tell me what the right thing is?

Sure. Here's the one-minute version of my personal vision for how 
string interpolation should work in D:

1. `writeln(i"Hello $name!")` lowers to `writeln("Hello ", name, 
2. `printf(f"Hello ${%s}name!")` lowers to `printf("Hello %s!", 
3. `f"Hello $name!"` and `i"Hello ${%s}name"` are parse-time 

The key idea is that rather than trying to find one magical 
solution that works for both writeln-style functions and 
printf-style functions, we have a dedicated syntax for each.

This won't stop people from calling functions with the wrong 
arguments, but I don't think it needs to--that should be each 
function's responsibility, not the language's (see: Scott Meyers' 
Year/Month/Day example). And if we do decide to make it the 
language's responsibility, we should do it in a way that solves 
the problem in the general case, like pragma(printf).

More information about the Digitalmars-d mailing list