RFC: Value range propagation for if-else

Lionello Lunesu via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 26 21:53:02 PDT 2014


On 23/06/14 04:51, "Nordlöw" wrote:
>> That will only work now if you use an "else".
>
> So you mean something like
>
>       if(x<byte.min || x>byte.max)
>           throw new InvalidArgumentException("...
>       else {}
>
> ?
>
> That seems like a strange restriction. Why is that?

I meant, else return x;

Because it's easy to see what the value of x is within the if and else 
body. It's not trivial to find out that the if body never exits (because 
of the throw) and therefor the code after the if is in essence the else 
body.

L.


More information about the Digitalmars-d mailing list