int nan
Denis Koroskin
2korden at gmail.com
Sat Jun 27 08:46:08 PDT 2009
On Sat, 27 Jun 2009 17:50:11 +0400, BCS <none at anon.com> wrote:
> Hello Nick,
>
>> Interesting idea, but IMO using NaN as a default initializer is just a
>> crutch for not having a real system of compile-time
>> detecting/preventing of uninitialized variables from being read (C#'s
>> system for this works very well in my experience).
>
> I think you can prove that it is impossible to do this totally correctly:
>
> int i;
>
> for(int j = foo(); j > 0; j--) i = bar(j); // what if foo() returns
> -5?
This code doesn't compile in C# and fails with the following error at
first attempt to use 'i':
error CS0165: Use of unassigned local variable 'i'
More information about the Digitalmars-d
mailing list