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

Adam D. Ruppe destructionator at gmail.com
Wed Feb 5 02:50:16 UTC 2020


On Tuesday, 4 February 2020 at 23:03:45 UTC, Adam D. Ruppe wrote:
> I just wrote up a revised DIP based on Walter's to detail my 
> current thoughts:
>
> https://gist.github.com/adamdruppe/a58f097d974b364ae1cbc8c050dd9a3f

So I didn't explicitly say this in the document, but you can 
prove it by running my sample code

void main() @nogc {
         string name = "interpolation";

         // I wrote out long form what
         // i"Hello, ${%s}(name.ptr)\n"
         // would be lowered to by hand.....
         printf(_d_interpolated_string!("Hello, ", 
_d_interpolated_format_spec("%s"), "\n")(), mixin("name.ptr"));
}


Observe how that *works* with @nogc.

Despite my specifically putting the format string builder inside 
a private method with an if(__ctfe) guard, called from a wrapper 
template to force a CTFE enum generating, it did not compile with 
-betterC, but this is a known bug in betterC, not a flaw with my 
proposal nor my sample implementation. See: 
https://issues.dlang.org/show_bug.cgi?id=19268

Of course, if we really wanted to, we could provide a separate 
implementation that works around the -betterC bug anyway, but 
even if we couldn't work around t, it would be ridiculous to 
cripple a new feature just because of a known bug in a niche dmd 
switch.


More information about the Digitalmars-d mailing list