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

Seb seb at wilzba.ch
Thu Jan 30 13:37:17 UTC 2020

On Thursday, 30 January 2020 at 13:20:47 UTC, Sebastiaan Koppe 
> On Thursday, 30 January 2020 at 12:39:39 UTC, Seb wrote:
>> Structs are essentially just fancy tuples and look the same 
>> when stored in memory. Hence, I don't see why all of the above 
>> can't be done by a templated struct?
>> A templated struct would give the user a lot more options 
>> through additional opt-in methods and allow APIs to overload 
>> for them (e.g. SQL).
> I reckon the answer is that it won't work with printf et al.

Yeah, but it would:

Option A) with .expand


Option B) with an overload in druntime

int printf(InterpolatedString)(InterpolatedString str) {
    return printf(str.expand)


Both options would work in BetterC too.

> Which I find ironic because I believe the people who want 
> interpolated strings most badly don't use printf at all.


> Still, it might just be that a templated struct will open up 
> more options with more upside than the downside of it not 
> supporting printf.


More information about the Digitalmars-d mailing list