DIP 1027---String Interpolation---Community Review Round 1
Adam D. Ruppe
destructionator at gmail.com
Sat Dec 14 21:10:42 UTC 2019
On Saturday, 14 December 2019 at 15:04:24 UTC, Steven
> What information does it lose?
The grouping of the items in the string. Tuples auto-flatten and
then the function cannot tell any more if they actually were
together to begin with.
The format string lets you reconstruct it though, assuming you
know to check for a format string. This is why I can work with
Walter's proposal, it would just be disappointing to lose the
overloading aspect of it.
> One other suggestion I had was to make the resulting string
> literal generated by interpolation be a derivative of a string
That's what an object with `alias toString this` is!
> Hm... I prefer it just working correctly.
We can do that with Phobos functions (and indeed anything written
after we decide on the interface), but printf's interface is
already locked down, so it is either just working there or having
an object, can't do both.... and I think that'd be a pity since a
compile error telling you to use ".asFormatString" is such an
> Not only that, but now you have to pull a lot of the library
> into druntime (std.format for example).
Solved problem: you'd make the method templated so it is only
pulled if used. The ^^ operator in D works like this already. No
need to actually bring it in to druntime, it will just reference
phobos iff used.
> What about the lifetime issues? An object is going to make a
> copy. Which may not be correct or possible.
So does a tuple passed to a function, there's no difference here
Remember, all my thing really boils down to is the compiler
inserting X!T instead of just T.
More information about the Digitalmars-d