--- Comment #5 from Jonathan M Davis <> 2011-07-18 14:46:24 
PDT ---
In pretty much every other language that I've ever used, null is _not_ the same
thing as empty _ever_. Someone coming from C, C++, Java etc. is going to expect
dynamic arrays to be able to be null. The way that you check for null in all of
those languages is either == 0 or == null (or == NULL or == nullptr). is does
not exist in any other language that I've ever seen. I fully expect programmers
from C, C++, Java etc. to expect == null to be checking whether an array is
null - that is whether is null is true. But it doesn't do that. It checks
whether length == 0.

The fact that an empty array an null are almost synonymous in D is incredibly
bizarre. It simplifies declaring an array and then appending it or setting its
length, but it is _not_ what your average programmer is going to expect coming
from other C-based languages. As such, I expect that == null risks being a
frequent newbie mistake. The only reason it wouldn't be is if not that many
newbies need to or care about checking for null.

The fact that



if(arr is null)

don't do the same thing is a related but separate issue, and should probably
also be addressed. But I really think that == null is a problem which is going
to throw off a lot of people. If I see it in code, I'm either going to point it
out or change it (depending on the circumstances). The odds are just too high
that it doesn't do what the programmer intended or that someone else reading
the code will misinterpret what it does.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to