Spec#, nullables and more
bearophile
bearophileHUGS at lycos.com
Sat Nov 6 02:04:59 PDT 2010
Walter:
> Suppose, for example, you are appending the numbers 1..5 to the array, and
> somehow appended a 17. Many moons later, something crashes because the 17 was
> out of range.
This bug doesn't happen in Ada (and Delphi), because you define a ranged integer type like this:
subtype Small is Integer range 1 .. 5;
To see an example of this, look at this "useless" site where I have put a small Ada program that you may run yourself, with some stdin data:
http://ideone.com/shF5j
I try to put inside the "inputx" variable the following numbers:
1
2
1
4
17
But at runtime it gives:
raised CONSTRAINT_ERROR : prog.adb:9 range check failed
Bye,
bearophile
More information about the Digitalmars-d
mailing list