On Wednesday, 3 October 2012 at 16:11:53 UTC, Franciszek Czekała wrote:
As my comments indicated : the presence of a value does not
guarantee a valid value by itself. The C++ declaration int n; introduces a value, good luck using it.
auto c = new Class();

Tell me, does c contain an invalid value now?

In short, having null references is useful (a value outside of the type cannot be introduced easily unless the language gives a hand, check eof() in C++ character_traits),
Null references are useful, that's right. Nobody wants to take them away. Just put something like a questionmark behind the reference type to indicate that it's nullable.

while forcing non-null references hardly offers any significant advantage.
1) Performance, no or very few null-checks.
2) Code is shorter, looks better, less duplications.
3) Clarity. User of functions know, whether a function can return null at compile time.

Not enough to justify complicating the syntax of the language to have it both ways.
Not really. It's all about one question mark for example.


Reply via email to