Discussion Thread: DIP 1036--String Interpolation Tuple Literals--Community Review Round 2
Steven Schveighoffer
schveiguy at gmail.com
Fri Jan 29 17:03:19 UTC 2021
On 1/29/21 10:26 AM, jmh530 wrote:
> On Friday, 29 January 2021 at 15:06:20 UTC, Steven Schveighoffer wrote:
>> [snip]
>>
>> With a metaprogramming wrapper, it would be:
>>
>> printf(i"${item} %02d${other_item}");
>>
>> Without a metaprogramming wrapper, you call it like this:
>>
>> printf("%s %02d", item, other_item); // yes, just use printf the way
>> it was intended
>>
>> The point of this is, we don't want to fit into printf-style
>> formatting, because it's too niche a need, and extremely limiting. Use
>> the wrapper if you want printf formatting. This is not a burden on
>> anyone (the wrapper took me 15 minutes to write, and is an inlineable
>> no-processing call).
>> [snip]
>
> Is there any reason why it needs to be an overload of printf instead of
> a separate function, like say iprintf?
>
No reason at all. But it's possible if you want to (as I showed). The
DIP provides the possibility for doing whatever you want, without
accidentally doing what you don't want.
-Steve
More information about the Digitalmars-d
mailing list