Rosettacode: program termination
bearophile
bearophileHUGS at lycos.com
Mon Apr 14 04:16:40 PDT 2014
John Colvin:
> I think notInifnite is too contrived, you would always just use
> `else` there. This is more realistic:
>
> int notInfinite(in int b) pure nothrow {
> if (b < 0)
> return 10;
> if (b > 10)
> return 20;
>
> // In release mode this becomes a halt, and it's sometimes
> // necessary. If you remove this the compiler gives:
> // Error: function test.notInfinite no return exp;
> // or assert(0); at end of function
> assert(false);
> }
OK, I have improved the code:
http://rosettacode.org/wiki/Program_termination#D
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list