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

Steven Schveighoffer schveiguy at gmail.com
Wed Dec 11 21:08:25 UTC 2019


On 12/11/19 3:59 PM, Andrea Fontana wrote:
> On Wednesday, 11 December 2019 at 20:38:49 UTC, Steven Schveighoffer wrote:
>>
>> This is very much focused on writef and printf. What about other 
>> functions that accept similar string + arg tuple, but don't use %s 
>> specifiers? Perfect example is SQL:
>>
>> query("select * from sometable where date < ?", someDate);
>>
>> With the interpolation string:
>>
>> query(i"select * from sometable where date < %someDate");
>>
>> This translates to:
>>
>> query("select * from sometable where date < %s", someDate);
>>
> 
> query(i"select * from sometable where date < %someDate".format);

https://en.wikipedia.org/wiki/SQL_injection

Besides, this is bad for performance, you are translating a type to a 
string, just to send it to the server, to have it translate it back into 
the type. Sending the type directly is much more efficient.

What I want is what I first typed, just in a nicer format. D has such 
great power at translating code, it should be able to do this. I don't 
see why we would settle for something that basically is a "nicer" writef 
or format when it could be used everywhere.

-Steve


More information about the Digitalmars-d mailing list