On Fri, 02 Mar 2012 16:21:00 -0500, Ali Çehreli <[email protected]> wrote:
On 03/02/2012 01:08 PM, Andrej Mitrovic wrote:
> Is there a reason why there's no .empty property for hashes? std.array
> defines it for arrays, and range types must have it defined.
Yes, empty is a part of the InputRange interface. Slices are InputRange
ranges but associative arrays are not. Unless they also provide front,
which would returns a tuple of key and value I guess, and popFront()
which would remove that key and value.
But things get interesting again because implementing empty, front, and
popFront() on the AA interface would conflate the collection with a
range.
Defining .empty for hashes does not make it a range. It could (should) be
defined. Just don't define popFront (which has little meaning anyway).
-Steve