Timon Gehr:

To quote (loosely) Mr. Walter Bright from another discussion: how many
current bugs in dmd are related to default null references?

More than zero.

A >0 frequency of bugs caused by something can't be enough to justify a language feature. You need a "high enough" frequency :-)

--------------------------

Alex Burton:

Doing null references in C++ is simple:

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

r = 3; // crash


IMHO int * p = NULL is a violation of the type system and should not compile.
NULL can in no way be considered a pointer to an int.

I don't agree. int* is a raw pointer, and a raw pointer is allowed to contain a null, so the first line is OK.

The problem is in the second line: in a better designed language this line needs to be a compile-time error, because p can be null, while r can't be null:

int& r = *p;

The language has to force you to initialize the reference with something that is valid.

Bye,
bearophile

Reply via email to