Re: [Vala] non-null broken in vala 0.9.3



Jiří Zárevúcky <zarevucky jiri    > writes:


tecywiz121 píše v Čt 15. 07. 2010 v 23:06 -0400:

Bringing static code analysis would be amazing, but I have a feeling
that detecting when a variable is considered safe is an undecidable
problem (http://en.wikipedia.org/wiki/Undecidable_problem ).  Not sure
though.


I wouldn't go into discussion about whether it's decidable or not. The
fact is that a much simpler variant of that problem (whether or not
there is an if statement or assertion whose condition ensures safety) is
entirely sufficient for vast majority of cases.

If what you mean would look like this:

Foo? a = bar();
// a is unsafe and can't be accessed
if (null != a)
{
// a is safe to use in this block
}

then I don't really see how that is any different than what we have now:

Foo? a = bar();
// a is unsafe and can't be accessed
if (null != a)
{
Foo b = (!)a;
// b is now safe to use
}

For the rest of them,
you'll just have one extra assert(), which is not a problem but rather a
good practice. 

Isn't the point of having non-nullable types to eliminate runtime checks?  When
testing your program, its very easy to miss cases that would lead to the
assertion failing, which is still a bug.

Thanks for reading,
Sam






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]