Introducing Nullable Reference Types in C#. Is there hope for D, too?
Timon Gehr
timon.gehr at gmx.ch
Wed Nov 22 13:47:19 UTC 2017
On 22.11.2017 05:55, codephantom wrote:
> ... >> The question isn't whether we should use the type system to prevent
>> bugs. The question is which set of problems really make sense to
>> prevent with the type system.
>>
>
> No, the question should be, what can the compiler prove to be
> true/false, correct/incorrect about your code, and what effort have you
> made in your code to assist the compiler to make that determination.
>
> If you've made no effort to provide the compiler with the context it
> needs to make a useful determination, then don't complain when the
> compiler gets it wrong. That is my first point.
>
> My second point, is that it is already possible to provide such context
> to the compiler, without having to make reference types non nullable,
> and therefore having to introduce a new nullable reference type.
> ...
It's really not.
> Which make more sense? Knowing that a reference type could potentially
> be null, and therefore check for null,
You are saying this as if there was always a reasonable thing to do if
the reference is in fact null. This is just not the case. I.e. this
option sometimes makes no sense. Also, if checking for null is always
required, why wouldn't the compiler complain if it is missing?
> or dealing with all the flow on
> conquences of making a reference type non nullable by default?
>
> Even with such a change, the Goldbach Conjecture still cannot be resolved.
>
If the correctness of a program depends on the Goldbach Conjecture,
that's still something one might want to know about. We could then just
add the correctness of the Goldbach conjecture as an assumption, and
then verify that under the given assumption, the program is actually
correct. Once the Goldbach conjecture gets resolved, we can get rid of
the assumption.
More information about the Digitalmars-d
mailing list