"Jacob Carlborg" <[email protected]> wrote in message news:[email protected]... > On 2012-03-21 04:54, Nick Sabalausky wrote: >> Hear me out... ;) >> >> Using empty seems to be emerging as the recommended practice for testing >> whether an array is empty. And that makes sense as it's consistent with >> other ranges. I'm all in favor of that. >> >> But I've found myself avoiding empty (and instead doing arr=="" or >> checking >> the .length) just because empty doesn't work on arrays unless you've >> already >> imported std.array (unless my knowledge is out-of-date, which is possible >> considering how fast things are moving ;) ). So doing "arr.empty" is a >> little messy and increases my cognitive load, whereas arr=="", arr==[], >> and >> arr.length == 0, "just work". >> >> Considering that: >> >> 1. Arrays are (from the user's perspective) a built-in type that doesn't >> need to be explicitly imported. >> >> 2. Calling 'empty' is (for good reason) the recommended standard practice >> for checking if arrays are empty. >> >> ...Perhaps it would make sense for empty(T)(T[] a) to be moved into >> object.d, or at least somewhere it will always be implicitly included? >> Being >> a standard part of arrays and input ranges already effectively elevates >> "empty" to a relatively special status anyway. > > Sure, why not. Do we want an "any" function as well, that is the opposite? >
I think "!array.empty" is plenty sufficient. Besides, there are other good uses of "any" that have been brought up before.
