The state of string interpolation
Sebastiaan Koppe
mail at skoppe.eu
Fri Dec 7 20:53:27 UTC 2018
On Friday, 7 December 2018 at 18:46:05 UTC, Steven Schveighoffer
wrote:
> But just for fun, let's compare to string interpolation
> strawman:
>
> text(iq"CODETEMPLATE
> void ${funcName}(${funcParams.formatted!"%-(%s, %)"}) {
> ${generateBoilerplate}
> for (i; 0 .. ${numIter})
> {
> ${generateFuncBody}
> }
> }
> CODETEMPLATE");
>
> Oh, and it requires zero library support. It just works, as if
> you called it with the parameters in the right place.
>
> With:
>
> alias argf = formatted!("%-(%s, %)";
>
> then the function declaration becomes:
> void ${funcName}(${funcParams.argf}) {
>
> -Steve
This is just plain awesome. I fail to see how anybody can be
against this. The more so when you consider it only requires a
small change to the frontend.
I especially like the formatted alias. It just keeps getting
better.
More information about the Digitalmars-d
mailing list