DIP 1027---String Interpolation---Format Assessment
Adam D. Ruppe
destructionator at gmail.com
Wed Feb 26 13:05:14 UTC 2020
On Wednesday, 26 February 2020 at 12:18:07 UTC, FeepingCreature
wrote:
> But to be thrice fair, Adam/Steven's proposal would work with
> the minor extension `f(i"hello $a".format)`/`f(i"hello
> $a".to!string)`, in keeping with the trend of GC use requiring
> explicit opt-in.
Actually, thanks to the new type, the sample code in my dip
offers an `idup` overload that works really easily for the users.
void foo(string s) {}
const(char)[] a;
foo(a); // doesn't work, but you can .idup it
foo(i"..."); // doesn't work, but you can .idup it too!
foo(i"...".idup); // indicates you are OK with the GC copy by
asking for one
so still really easy to use while being in line with D's existing
features. No GC if you don't want it, easy GC if you do.
More information about the Digitalmars-d-announce
mailing list