Discussion Thread: DIP 1036--String Interpolation Tuple Literals--Community Review Round 2
Walter Bright
newshound2 at digitalmars.com
Thu Jan 28 07:44:05 UTC 2021
On 1/27/2021 11:16 PM, Dukc wrote:
> On Thursday, 28 January 2021 at 06:12:14 UTC, Walter Bright wrote:
>> It appears to have abandoned being usable with printf?
>
> Well a simple way is `printf("%s", text(i"hello ${name1}, ${name2} and
> {name3}!"))`. Works, but not in a no-gc way unless you redefine `Interp!()`
> yourself.
Nobody is going to prefer calling printf that way.
Redefining a custom Interp template is a no-go, too, as then the code is
incompatible with common usage code.
> Even without touching `Interp!()` you could do a function that prints an
> interpolated string with `printf` without using the GC, as long as the format
> specifier is known at compile time. The function introspects the received
> `Interp!string` struct types and makes the correct format specifier from them at
> compile-time and feeds it along with rest of the arguments to `printf`. This is
> more complicated of course.
Sounds complicated enough to be a non-starter.
More information about the Digitalmars-d
mailing list