On 18.11.2017 05:05, Walter Bright wrote:
On 11/17/2017 6:05 AM, Timon Gehr wrote:
There are type systems that do that, which is what is being proposed for C#. It's pretty straightforward: If I have a variable of class reference type C, it actually contains a reference to a class instance of type C.

One of the difficulties with this is you'll still need an "empty" instance of C for the non-null reference to point to.

Why would you need an empty instance? Just use a Nullable!C instead of a C if a special 'null' state is actually required.

Any attempts to use a method on the empty instance should throw.

The idea is that the type system makes potential such attempts explicit while verifying that they don't occur in most of the cases. Then you can grep for potential null dereferences.

Reply via email to