The state of string interpolation
Adam D. Ruppe
destructionator at gmail.com
Sat Dec 8 03:00:29 UTC 2018
On Saturday, 8 December 2018 at 02:49:46 UTC, H. S. Teoh wrote:
> Hmph. I forgot about this limitation of compile-time tuples
> aka AliasSeq: you cannot capture expressions this way. :-(
The problem with AliasSeq!() is the !() part - it is passing them
as compile-time arguments, and thus it must be available at
compile time *for the template it is being passed to*.
But the compiler itself has no such limitation. And as proof,
consider std.traits.Parameters. You can set items in that to
runtime values and pass them to functions... just not *templates*
because the variables a+b need to be available.
Also, struct.tupleof works fine. We aren't capturing expressions
per se, we are capturing the values of those evaluating those
expressions. Passing it to a compile time thing would complain,
but passing it to a runtime function would be fine, just like how
Template!(a+b)
only works if they can be CTFE'd, whereas
Function(a+b)
is totally fine
More information about the Digitalmars-d
mailing list