DIP 1027--String Interpolation--Final Review Discussion Thread

Steven Schveighoffer schveiguy at gmail.com
Tue Feb 4 21:49:18 UTC 2020


On 2/4/20 1:41 PM, jmh530 wrote:
> On Tuesday, 4 February 2020 at 14:33:59 UTC, Adam D. Ruppe wrote:
>> [snip]
> 
> One thing I'm a little confused on with this proposal. Under DIP 1027, 
> if I have a function that takes an string as input, then I believe it 
> can take an interpolated string as input instead. Similarly, it works 
> with printf.
> 
> Under the addendum proposal, is it also the case that functions that 
> take strings or printf can instead take the interpolated string? You 
> have some comments about that it does have compatability with printf and 
> there was some discussion about a toString method, but I wasn't 100% 
> sure where that came down and why.

The intention is for __d_interpolatedString (or whatever) to return a 
struct that has an enum member which is the interpolated format string, 
which is then alias this'd to the struct.

So the type should decay exactly into what the current DIP says. It 
should be 100% compatible with printf.

But if you want to do something different with interpolated strings, you 
can overload your function to handle it specially. Once you do that, you 
have access to the original parsed interpolation string parts and formats.

In short -- anything that would work with the DIP as currently written 
would work with this new proposal.

-Steve


More information about the Digitalmars-d mailing list