DIP 1027--String Interpolation--Final Review Discussion Thread

Steven Schveighoffer schveiguy at gmail.com
Sun Feb 2 20:34:17 UTC 2020


On 2/2/20 3:18 PM, Walter Bright wrote:
> On 2/2/2020 10:46 AM, Steven Schveighoffer wrote:
>> This works just fine:
> 
> That's a good point.
> 
> But it took me a moment to understand the `printf(5)` because what 
> printf is is very deeply ingrained in me, hence I would not write code 
> like that and wouldn't find it acceptable. It's jarring and misleading.
> 
> (I used to use clever printf macros in C to alter printf's behavior, but 
> eventually removed all that for the same reason.)

The printf(5) was just to show it can be overloaded. The real use case 
would be the interpolated string struct that everyone is discussing here 
(which you objected to), not adding integer printing ;). It's just that 
I can get that to work to demonstrate the overloadability of C functions.

In essence:

printf(i"I have $apples apples and $bananas bananas");

Works in both scenarios. With the DIP as-is (and no extra implementation 
in the library), and with the interpolated-string-to-struct idea (with a 
D-based shim as an overload).

Not arguing against the DIP, or for the struct mechanism, but just 
against that objection.

-Steve


More information about the Digitalmars-d mailing list