https://d.puremagic.com/issues/show_bug.cgi?id=4733
--- Comment #16 from [email protected] 2013-11-27 03:16:45 PST --- (In reply to comment #14) > I would prefer that the warning consider arr.length != 0 more than > std.array.empty. Nothing else. Hope you understand me now. Suggesting people to use length is not a good idea. For that semantics there is empty that is safer and more clean, and it's the preferred idiom in D code. (I have an enhancement request to extend the "empty" to work on associative arrays too, Issue 6409 ). The problem yebblies is explaining is that the code going to be disallowed is "if(arr)" that doesn't have the same semantics as "if(!arr.empty)", despite the programmer often meant that semantic. "if(arr)" is semantically unclean, that's why I have written this tiny breaking enhancement request to disallow it. And it's right such semantic confusion that makes it harder to write a good warning message for this. "converting dynamic arrays to boolean is deprecated, instead use std.array.empty or arr.ptr" That message confuses a bit the "std.array" module with the "array" as the data to work on. So an alternative is to write the name of the real array used in the code: int[] foo; if (foo) {} ==> "converting dynamic arrays to boolean is deprecated, instead use std.array.empty or foo.ptr" I think this is the best simple warning I can think of for now. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
