What about putting array.empty in object.d?
Steven Schveighoffer
schveiguy at yahoo.com
Wed Mar 21 10:22:53 PDT 2012
On Wed, 21 Mar 2012 11:50:46 -0400, Xinok <xinok at live.com> wrote:
> On Wednesday, 21 March 2012 at 04:54:54 UTC, Daniel Murphy wrote:
>> FWIW, I would rather see `if (array)` translated to `if (array.length)`
>> and
>> this become the recomended way to check if an array is empty. Wouldn't
>> that
>> remove the dependency on std.array for most of the cases?
>
> Nope. .length is a requirement for finite random-access ranges, but not
> for forward or bidirectional ranges. .empty is the only primitive
> required by all input ranges.
>
> So if you pass an array to a function expecting a forward range, it may
> not work if the primitive .empty doesn't exist.
from std/range.d:
module std.range;
public import std.array;
-Steve
More information about the Digitalmars-d
mailing list