References in D

Ziad Hatahet hatahet at gmail.com
Tue Oct 2 23:20:09 PDT 2012


On Mon, Sep 24, 2012 at 5:23 AM, Regan Heath <regan at netmail.co.nz> wrote:

> What I've noticed looking at Java code written by others is that null as a
> possible state is ignored by the vast bulk of the code, which is completely
> the opposite when reviewing C/C++ code where null is checked for and
> handled where applicable.  I think it's a mindset thing brought on by the
> language, or how it's taught, or something.  It seems to me that Java would
> have benefited from non-null references :p
>
>
Just because (from your experience) null checks are more prevalent in C or
C++ compared to Java does not mean that any of those languages could not
benefit from non-nullable types. The entire point is to statically prove
that a certain reference/pointer cannot be null. You are better able to
reason about the code, and it is done at compile time with no run time
overhead. Furthermore, you avoid the possibility of forgetting to put in
the checks in the first place.

--
Ziad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20121002/36cea32b/attachment-0001.html>


More information about the Digitalmars-d mailing list