String interpolation, after a healthy debate on discord
deadalnix
deadalnix at gmail.com
Fri Dec 10 13:13:14 UTC 2021
On Thursday, 9 December 2021 at 21:06:11 UTC, WebFreak001 wrote:
> The simpler syntax would be an additional special function
> calling syntax (only valid for functions accepting the
> interpolated strings with the header as suggested by YAIDIP)
>
> Example:
> ```d
> string text(T...)(T args) if (isInterpolatedString!T) { ... }
>
> // could then be called:
>
> text"Hello $name!";
>
> // translates to:
> text(i"Hello $name!");
>
> // translates to:
> text(InterpolationHeader!("Hello ", "name", "!"), "Hello ",
> name, "!");
> ```
>
This is much better. You'll note that the `i""` doesn't need to
be backed in the language anymore with that construct and can be
written as a library, if you define the rewrites the other way
around.
More information about the Digitalmars-d
mailing list