The state of string interpolation
John Chapman
johnch_atms at hotmail.com
Sat Dec 8 09:39:40 UTC 2018
On Saturday, 8 December 2018 at 03:04:35 UTC, Steven
Schveighoffer wrote:
> I'm yet unclear yet whether the implementation behaves that
> way, but if it doesn't we should just change it so it does. But
> he has said (a bit ambiguously) that it does do expressions
> (comment in that PR).
>
> If we can't get arbitrary expressions to work at runtime, then
> this proposal is no good.
>
> -Steve
It definitely does do expressions. The implementation just calls
"parseExpression" for stuff inside '$(…)'.
int fun(int n) { return n; }
string hal = "HAL";
assert(i"$(hal) $((() => 1_000)() * 8 + fun(1_000))".text == "HAL
9000");
More information about the Digitalmars-d
mailing list