On Thursday, 4 July 2013 at 13:32:25 UTC, Steven Schveighoffer wrote:
Indeed. IMO if(arr) should mean if(arr.ptr) .. and I thought it did.. or did this change at some point?

No, it should mean if(arr.length).

*I* think it should simply mean compilation error. There is, arguably, a "big" difference between null and empty:

null means not yet initialized, whereas empty means initialized, but contains no info. This is an important distinction for things such as lazy initialization, or just plain checking data integrity. It can also mean important distinctions for serialization, such as JSON or xml, to differentiate between an null node, or a node that contains nothing.

A slice is the abstraction of both pointer and container. Wanting to test null pointer or empty are both legitimate operations.

IMO, you should have to state which you want. Making arbitrary choices for the user in the face of ambiguity is evil.

Reply via email to