Feedback Thread: DIP 1036--String Interpolation Tuple Literals--Community Review Round 2
Daniel N
no at public.email
Wed Feb 3 20:02:57 UTC 2021
On Wednesday, 27 January 2021 at 10:33:53 UTC, Mike Parker wrote:
> This is the feedback thread for the second round of Community
> Review of DIP 1036, "String Interpolation Tuple Literals".
>
There are many great qualities of DIP1036 and I hope it gets
accepted, good luck!
But one area which I think could need improvement is:
1) The lowering (either that or I totally overlooked something
obvious again).
writeln(i"I ate ${apples} apples and ${bananas} bananas totalling
${apples + bananas} fruit.");
DIP1036 proposes the following rewrite:
writeln(interp!"I ate "(), apples, interp!" apples and "(),
bananas, interp!" bananas totalling "(), apples + bananas,
interp!" fruit."());
Wouldn't this lowering be both simpler and more more efficient?
writeln(interp!"I ate "(), apples, " apples and ", bananas, "
bananas totalling ", apples + bananas, " fruit.");
Actually couldn't we go even futher?
immutable interp interp_tag; // an instance of some unique type
with as low overhead as possible
writeln(interp_tag, "I ate ", apples, " apples and ", bananas, "
bananas totalling ", apples + bananas, " fruit.");
This way you can overload with a normal function argument instead
of using a template constraint and NO single template instance is
created.
2) Also no fan of using abbreviated type-names(interp) in
userfacing API:s
More information about the Digitalmars-d
mailing list