Cannot Qualify Variadic Functions with Lazy Arguments as nothrow

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 14 02:53:18 PDT 2015


At

https://github.com/nordlow/justd/blob/master/algorithm_ex.d#L43

I've implemented a function either() with behaviour similar to 
the `or` function/operator in dynamic languages such as Python 
and Lisp.

I'm almost satisified with it except that the lazy evaluation at

https://github.com/nordlow/justd/blob/master/algorithm_ex.d#L45

cannot be made nothrow.

If I qualify the function as nothrow DMD complains as

algorithm_ex.d(45,16): Error: 'a' is not nothrow
algorithm_ex.d(46,29): Error: '_param_1' is not nothrow

I don't see a reason why any of these two cases should throw.

The same problem occurs if I make the implementation use only one 
function and check the recursion termination case with `static if 
(bs.length == 1)` instead.

Is there a workaround for this?


More information about the Digitalmars-d-learn mailing list