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

Jab jab_293 at gmall.com
Sun Dec 15 05:34:48 UTC 2019


On Sunday, 15 December 2019 at 04:20:59 UTC, Walter Bright wrote:
> On 12/14/2019 5:52 PM, Adam D. Ruppe wrote:
>> On Sunday, 15 December 2019 at 01:44:18 UTC, Walter Bright 
>> wrote:
>>> The extra syntax kills it
>> This is true, but ONLY for the printf case. It just works in 
>> all other cases.
>
> printf is a very important case, and it kills it for scanf and 
> every other function that takes a format string (dmd itself has 
> many printf-like functions).

IIRC you said dmd was just a direct translation from C and 
carries all that legacy debt. Is that really an example you want 
to be using to justify your point?

>>> It's just not the default.
>> Which is usable (that's why I'm not opposed to your proposal) 
>> but means it is now impossible to catch accidental misuses at 
>> compile time. They type system no longer helps you.
>
> That's always been true with printf. Many C compilers have 
> extensions to deal with this, but D never incorporated them 
> (although it could).

You don't need to add an extra feature and warnings to the 
compiler. There's already a type system that can be used. Also 
that feature isn't that simple to implement. I see all the hacks 
to get around it in android's kernel source. They treat the 
warning as an error, even with the hacks in the source code. It 
still gives false positives and I end up disabling it or just 
deleting the logs that are causing the error.

If it was important it would already have been implemented, but 
no one uses printf as there are better alternatives.




More information about the Digitalmars-d mailing list