Mixin operator 'if' directly
Nicholas Wilson
iamthewilsonator at hotmail.com
Sat Dec 22 09:47:13 UTC 2018
On Saturday, 22 December 2018 at 03:44:09 UTC, Timoses wrote:
> 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);
> }
https://issues.dlang.org/show_bug.cgi?id=19506
More information about the Digitalmars-d-learn
mailing list