Spec#, nullables and more

Walter Bright newshound2 at digitalmars.com
Sat Nov 6 11:14:15 PDT 2010


Rainer Deyke wrote:
> On 11/6/2010 02:42, Walter Bright wrote:
>> Adam D. Ruppe wrote:
>>> It wasn't until I added the invariant and in/out contracts to all the
>>> functions
>>> asserting about null that the problem's true cause became apparent.
>> Couldn't this happen to you with any datum that has an unexpected value
>> in it?
>>
>> 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.
> 
> That's an argument for limited-range data types, not against
> non-nullable types.

I see it more as an argument for any restricted subset of a data type. It could 
be that you want just odd numbers in the array, and an even one crept in.


More information about the Digitalmars-d mailing list