6 ms·
Yes Making null assignable to anything results with all kinds of nonsense. For example, to say that any class implements an interface is now nonsense - as long
by spion 11y ago
Yes
Making null assignable to anything results with all kinds of nonsense. For example, to say that any class implements an interface is now nonsense - as long as nullable values are assignable to that type, there is no guarantee at all.
You now have this nice and fancy type system... with this giant gaping hole that lets all hell break lose. And then we wonder why people are skeptical of the claim that statically typed languages help with correctness.
- jasode 11y ago>For example, to say that any class implements an interface is now nonsense - as long as nullable values are assignable to that type You're talking about a different concept of "null" from the parent you're replying to (junto). You're talking about "null" as invalid object reference (similar to uninitialized pointer in C/C++). junto was asking about "null" as a sentinel value for semantics of "missing" or "unknown" data. This is a very desirable language feature to have. Your complaint about "null references" is valid but it's further confusing the misunderstanding junto appears to have about Nullable<T>. Nullable<T> isn't about invalid object references. Instead, it's a convenient language feature that combines two booleans to expose the desirable semantics of a tri-state boolean. The 1st bool is the user named variable. The 2nd bool is the .HasValue property. Instead of explicitly setting .Hashvalue=false, C# just lets programmer use "null".