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

Adam D. Ruppe destructionator at gmail.com
Mon Feb 3 14:52:24 UTC 2020


On Monday, 3 February 2020 at 14:37:22 UTC, Steven Schveighoffer 
wrote:
> I'd do it a little different, so we don't throw away the work 
> the compiler already did:
>
> i"$apples and ${%d}bananas"
>
> =>
>
> (__d_format_literal!(Format.init, " and ", Format("%d")), 
> apples, bananas)

Yes, that would be excellent. If you make a motion to amend the 
DIP, I'll withdraw my motion and second yours. Let's form a 
coalition and get Walter onboard!

With this, there's no more magic %s from the compiler (though 
Format.init can and prolly should just return "%s") and there's 
no more need for % => %% since the library can reliably detect 
everything.

I'd just note that `Format` here is more realistically 
`__d_format_item` or something, a new simple thingy rather than a 
complex phobos struct or whatever.

> If there is an overload that takes whatever this returns, then 
> this is used as the lowering. Otherwise, a string literal as 
> specified by the DIP is used (or we have an alias this in the 
> result to the string version).

yeah just alias this it. Let's not put too much magic in there 
when we already have a library solution with lowering.



More information about the Digitalmars-d mailing list