Interpolated strings and SQL
Nickolay Bukreyev
buknik95 at ya.ru
Wed Jan 10 15:25:17 UTC 2024
On Wednesday, 10 January 2024 at 15:07:42 UTC, Nickolay Bukreyev
wrote:
> ```d
> writeln(interpolate!i"prefix $(baz + 4) suffix");
> // Desugars to:
> writeln(interpolate!(
> InterpolationHeader(),
> InterpolatedLiteral!"prefix "(),
> InterpolatedExpression!"baz + 4"(),
> baz + 4,
> InterpolatedLiteral!" suffix"(),
> InterpolationFooter(),
> ));
> // `interpolate!(...)` would expand to:
> writeln("prefix ", baz + 4, " suffix");
> ```
Well, `InterpolatedLiteral` and `InterpolatedExpression` don’t
have to be templates anymore:
```d
writeln(interpolate!i"prefix $(baz + 4) suffix");
// Desugars to:
writeln(interpolate!(
InterpolationHeader(),
InterpolatedLiteral("prefix "),
InterpolatedExpression("baz + 4"),
baz + 4,
InterpolatedLiteral(" suffix"),
InterpolationFooter(),
));
// `interpolate!(...)` would expand to:
writeln("prefix ", baz + 4, " suffix");
```
More information about the Digitalmars-d
mailing list