The state of string interpolation
Adam D. Ruppe
destructionator at gmail.com
Fri Dec 7 03:00:54 UTC 2018
On Friday, 7 December 2018 at 02:38:30 UTC, Mike Franklin wrote:
>> We kinda-sorta can, with `lazy void`.
>
> I'm not sure what you mean. Please elaborate.
It is the runtime version of what Steven gave.
void foo(lazy int something) {
import std.stdio;
writeln(something);
}
void main() {
int a = 1, b = 2;
foo(a + b);
}
And you can `lazy void` too, which takes anything which has an
effect (it is an error if it has no effect), but discards its
return value. example here:
https://dlang.org/spec/function.html#lazy-params
The compiler simply wraps the expression you pass to the argument
in a delegate, and automatically calls any reference to it (so
the ref of something above actually does something())
More information about the Digitalmars-d
mailing list