On 5/18/2013 9:42 PM, Jonathan M Davis wrote:
On Saturday, May 18, 2013 21:30:57 Walter Bright wrote:
On 5/18/2013 9:06 PM, Jonathan M Davis wrote:
The closest that there is is
C++'s references, which aren't rebindable and in many ways act more like
aliases than pointers.

You can trivially create null references in C++:

int* p = NULL;
int& r = *p;

Yes, but they're designed with the idea that they're non-nullable. You can't
assign NULL to them or check if they're NULL. It's just that it's possible to
make them NULL by the trick that you just showed.

I don't even think it's a trick, as it can easily happen unintentionally.

Really, it's an example of
how C++ references are more like aliases than pointers (much as they're
pointers underneath the hood). All around, they're a bad example of a non-
nullable pointer even though that's kind of what they're supposed to be in
principle.

- Jonathan M Davis


Reply via email to