Non-null objects, the Null Object pattern, and T.init

Walter Bright newshound2 at digitalmars.com
Fri Jan 17 18:41:58 PST 2014


On 1/17/2014 6:18 PM, Michel Fortin wrote:
> Implemented well, it makes it a compilation error. It works like this:
>
> - can't pass a likely-null value to a function that wants a not-null argument.
> - can't assign a likely-null value to a not-null variable.
> - can't dereference a likely-null value.
>
> You have to check for null first, and the check changes the value from
> likely-null to not-null in the branch taken when the pointer is valid.


I was talking about runtime errors, in that finding the cause of a runtime null 
failure is not harder than finding the cause of any other runtime invalid value.

We all agree that detecting bugs at compile time is better.



More information about the Digitalmars-d mailing list