Null references redux

Michel Fortin michel.fortin at michelf.com
Sat Sep 26 20:28:30 PDT 2009


On 2009-09-26 22:07:00 -0400, Walter Bright <newshound1 at digitalmars.com> said:

> [...] The facilities in D enable one to construct a non-nullable type, 
> and they are appropriate for many designs. I just don't see them as a 
> replacement for *all* reference types.

As far as I understand this thread, no one here is arguing that 
non-nullable references/pointers should replace *all* reference/pointer 
types. The argument made is that non-nullable should be the default and 
nullable can be specified explicitly any time you need it.

So if you need a reference you use "Object" as the type, and if you 
want that reference to be nullable you write "Object?". The static 
analysis can then assert that your code properly check for null prior 
dereferencing a nullable type and issues a compilation error if not.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list