DIP 1027--String Interpolation--Final Review Discussion Thread
Adam D. Ruppe
destructionator at gmail.com
Thu Jan 30 13:34:52 UTC 2020
On Thursday, 30 January 2020 at 13:20:47 UTC, Sebastiaan Koppe
wrote:
> That is of course always the problem of catering to a large
> group.
A struct is the best option for a large group since it can add
methods to handle different scenarios.
Like I said in the last thread, it is fairly easy to make it work
with a struct:
i"printf works too: %n2 %n\n".c.tupleof
Yes, you must call a method on it and explicitly do tupleof under
current language rules. But it *is* possible and not even that
weird.
And if you don't do that, the compiler will throw a helpful type
error message that could even tell you what to do!
Then this is also possible several other things too. In my file,
I also show that:
string s = i"..."; // just works, via `alias toString this;`
writeln(i"..."); // just works; writeln calls the toString method
too
other_random_function(i"..."); // other_random_function can
recognize the special type and do various library things to it
too!
See my poc here: http://arsdnet.net/inter.d just pretend the
`mixin(interpolate!(` wasn't there, since under the new DIP the
language would do that part instead of the library.
We CAN have it all.
More information about the Digitalmars-d
mailing list