Mixin operator 'if' directly
Timoses
timosesu at gmail.com
Sat Dec 22 03:44:09 UTC 2018
On Wednesday, 19 December 2018 at 15:40:50 UTC, Neia Neutuladh
wrote:
> On Wed, 19 Dec 2018 15:12:14 +0000, bauss wrote:
> Or while instantiating it:
>
> mixin template foo()
> {
> int _ignoreme()
> {
> if (readln.strip == "abort") throw new AbortException;
> return 1;
> }
> int _alsoIgnoreMe = _ignoreme();
> }
> void main()
> {
> mixin foo;
> }
Awesome hack!
Being a hack, it would be even nicer if it worked ouf of the box:
mixin template foo(bool b)
{
int _impl() { writeln(b); return int.init; }
int _ipml2 = _impl();
}
vs
mixin template foo(bool b)
{
writeln(b);
}
More information about the Digitalmars-d-learn
mailing list