[Issue 6346] Make == null a warning for arrays
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jul 18 13:31:03 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6346
Steven Schveighoffer <schveiguy at yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |schveiguy at yahoo.com
--- Comment #2 from Steven Schveighoffer <schveiguy at yahoo.com> 2011-07-18 13:25:45 PDT ---
I disagree with the idea that == null is so bad to require a warning.
Note that .empty requires importing std.array, and arr.length == 0 doesn't read
as well as array == null.
Also note that the problem with classes (actually this has been fixed) is that
obj == null would cause a segfault if obj actually was null. The distinction
between arr == null and arr is null is far more subtle and far less dangerous.
Also, this change makes code behave inconsistently.
For example:
foo(int[] y)
{
int[] x = null;
if(y == x) // ok
{}
else if(y == null) // warning???
}
What happens if the former is folded into the latter during optimization?
I'd argue this is not worth a change to the language warnings.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list