Lazy param with nothrow

Andrea Fontana via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Mar 1 06:30:27 PST 2016


On Tuesday, 1 March 2016 at 13:41:38 UTC, Nemo wrote:
> On Tuesday, 1 March 2016 at 13:35:08 UTC, Andrea Fontana wrote:
>> This very very simple function [1] won't compile.
>> It says that param t is not nothrow. Why? What's wrong with 
>> this?
>>
>> http://dpaste.dzfl.pl/bfc382e62711
>
> writeln isn't nothrow so you can't call it from test which is 
> nothrow without a try .. catch.
> The error message is misleading.

You are right about writeln & nothrow but the problem is still 
there if instead of:

writeln(t);

you write:

t;

(that's a reduced example, in real code I don't use writeln or 
other non-nothrow functions)


More information about the Digitalmars-d-learn mailing list