Feedback Thread: DIP 1036--String Interpolation Tuple Literals--Community Review Round 2

Walter Bright newshound2 at digitalmars.com
Fri Jan 29 08:26:33 UTC 2021


 > in DIP1027, formatting was a central component of interpolation. What became 
clear as the prior version was reviewed was that the complexity of specifying 
format while transforming into a parameter sequence was not worth adding to the 
language.

Not clear to me that ${?} is that complex, and the language itself did not need 
to know what the format was, it just had to fit inside the ${ }.

 > In particular, many applications of string interpolation did not fit well 
with format specifications (the sql example above being one of them),

I showed how it would work, see example at end.

 > and the end result was something that seemed focused solely on writef and 
printf functions.

Much more accurately, it was optimized for all functions that use either 
printf-style formatting strings or writef-style formatting functions. This is 
because those style functions are overwhelmingly used in D programs and are 
everywhere in C code.

In another post I compared #DIP1027 and #DIP1036 side-by-side for printf and 
writeln. (DIP1036 also requires an overload of writefln to work with anything 
other than %s formatting.)

Let's compare mysql:

DIP1036:

mysql_query(i"select * from foo where id = ${obj.id} and val > ${minval}");

DIP1027:

mysql_query(i"select * from foo where id = ${?}(obj.id) and val > ${?}minval");

The DIP1027 could be shorter or longer, depending on if the ( ) were needed or 
not. DIP1036 also requires a user-written overload for mysql_query(), DIP1027 
does not. DIP1036 is not a clear winner for mysql.


More information about the Digitalmars-d mailing list