The state of string interpolation
Mike Franklin
slavo5150 at yahoo.com
Fri Dec 7 02:38:30 UTC 2018
On Friday, 7 December 2018 at 01:19:35 UTC, Adam D. Ruppe wrote:
> On Friday, 7 December 2018 at 00:43:43 UTC, Mike Franklin wrote:
>> Can that be extended somehow to pass around expressions too
>> (i.e. expressions as rvalues)?
>
> We kinda-sorta can, with `lazy void`.
I'm not sure what you mean. Please elaborate.
Steven gave this example[1] here:
> This doesn't work:
>
> foo!(a + b);
>
> But this does:
>
> foo!(() => a + b);
What I'm thinking is if `foo` is declared as `foo(alias a)`, then
`a` could either accept either a symbol (currently possible) or
an expression (not currently possible; this is what I meant by
"expressions as rvalues"). Depending on how the body of `foo`
utilized `a` it could more or less do the equivalent of `foo!(()
=> a + b)`.
Mike
[1] - https://forum.dlang.org/post/puc2f3$27tr$1@digitalmars.com
More information about the Digitalmars-d
mailing list