[Issue 15738] Problem with std.experimental.ndslice empty()

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Mar 5 10:07:45 PST 2016


https://issues.dlang.org/show_bug.cgi?id=15738

--- Comment #3 from Илья Ярошенко <ilyayaroshenko at gmail.com> ---
(In reply to bearophile_hugs from comment #2)
> (In reply to Илья Ярошенко from comment #1)
> > This is feature, empty is empty!0, so it checks only first dimension. In
> > addition, this  is very important for optimization reasons. emptyAny method
> > may be added for desirable behavior.
> 
> I think it's a trap. empty === enoty!0 is not explicit. So it should be
> designed the other way, in an explicit way. If you want to add a empty()
> method, it should work on the whole tensor. If you want to see if one
> coordinate is empty, you can add a more specialized method, like emptySide,
> or something similar.

Slice is not a container, so there is no reason for such behavior.

`empty` must be as fast as possible because a user may use slices with
std.algorithm and std.range.

--


More information about the Digitalmars-d-bugs mailing list