RFC: Value range propagation for if-else

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 18 12:58:44 PDT 2014


On Wed, Jun 18, 2014 at 07:54:02PM +0000, Meta via Digitalmars-d wrote:
> On Wednesday, 18 June 2014 at 17:00:36 UTC, bearophile wrote:
> >Lionello Lunesu:
> >
> >>Will play with it.
> >
> >And later you look at other things, like post-conditions:
> >
> >
> >int foo()
> >out(result) {
> >    assert(result >= 0 && result <= ubyte.max);
> >} body {
> >    return 10;
> >}
> >void main() {
> >    ubyte x = foo();
> >}
> >
> >
> >And slowly D Contract Programming starts to become a grown-up
> >language feature.
> >
> >Bye,
> >bearophile
> 
> This could be a bad thing. It makes it pretty enticing to use
> contracts as input verification instead of logic verification.

Until you compile with -release, and then suddenly invalid input crashes
your program. :-P (Then you'll go and fire the guy who wrote it.)


T

-- 
"The whole problem with the world is that fools and fanatics are always
so certain of themselves, but wiser people so full of doubts." --
Bertrand Russell.
"How come he didn't put 'I think' at the end of it?" -- Anonymous


More information about the Digitalmars-d mailing list