Discussion Thread: DIP 1036--String Interpolation Tuple Literals--Community Review Round 2

Adam D. Ruppe destructionator at gmail.com
Tue Feb 2 13:28:52 UTC 2021


On Tuesday, 2 February 2021 at 08:16:11 UTC, Max Haughton wrote:
> Cheap solution: p"Blah blah {blah}" for printf style, i"xyz" 
> for everything else?

Or just a (zero runtime cost!) library function which is possible 
with the dip as-is. D excels at these things and there's no need 
to special case the compiler for it.

No more literal tokens will be added to this DIP. No qq"", no 
p"". It is all off the table.

The only major question I'm willing to entertain at this point is 
if the implicit string conversion is worth the cost. Everything 
else needs to be focused on getting the other little details 
right (like whatever it does with mixin)

BTW I have a 80% implementation up already (no implicit string 
impl and only i"" syntax added) so you can play with it yourself:

https://github.com/dlang/dmd/compare/master...adamdruppe:string_interp

The druntime components are

struct interp(string s) { string toString() const { return s; } }


And repeat for wstring and dstring if you like. Those must be in 
object.d for it to work.


For the demo, just use phobos' std.conv.text to convert it to a 
plain string (string s = i"anything".text;) or start writing your 
own functions to really explore the possibilities.



More information about the Digitalmars-d mailing list