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

Sebastiaan Koppe mail at skoppe.eu
Tue Feb 4 14:55:11 UTC 2020


On Tuesday, 4 February 2020 at 14:33:59 UTC, Adam D. Ruppe wrote:
> [...] consider this:
>
>    Window createWindow(string title, int width = 0, int height 
> = 0) {}
>
> and the user writes
>
>    createWindow(i"Window for $user_id on $pid")
>

You made some good arguments about why structure is needed 
(versus having a string + a tuple), but this is a really good 
example.

If anything the i"" should not return a string, but rather an 
InterpolatedString type (whatever that is).

This not only allow overloading/static-if on it, but also the 
possibility to introspect it. For instance to extract the 
original string.


More information about the Digitalmars-d mailing list