Template mixin statements?
Simen Kjærås
simen.kjaras at gmail.com
Fri Jan 18 11:45:01 UTC 2019
On Friday, 18 January 2019 at 11:07:10 UTC, NaN wrote:
> Template mixins can only mixin declarations. Was it ever
> considered to allow them to mixin statements? Is it ever likely
> to be added? Or are there reasons it wasnt allowed?
It's been suggested many times. Some explanation for why it's not
allowed is in https://issues.dlang.org/show_bug.cgi?id=1734, but
the motivations for disallowing it aren't really clear there.
Anyways, there is of course a workaround:
mixin template tmp() {
auto __tmp = (() => i = 3)();
}
unittest {
int i = 0;
mixin tmp!();
assert(i == 3);
}
--
Simen
More information about the Digitalmars-d
mailing list