Why does `filterBidirectional` exist, and why isn't it called `filter`?

JG someone at simewhere.com
Sun Mar 12 19:17:23 UTC 2023


On Thursday, 9 March 2023 at 08:06:02 UTC, FeepingCreature wrote:
> Yes I know the stated reason, to save time initializing the 
> range in `filter`.
>
> You know what I did because we didn't know 
> `filterBidirectional` existed?
>
> I literally *walked the entire range* returned by `filter` to 
> find the last matching element.
>
> `filter` should expose `back`. By all means, let `back` lazily 
> initialize, but I don't understand how `filterBidirectional` 
> was ever considered acceptable. Since when do we sacrifice ease 
> of use for performance? I mean, since 2011 apparently. - This 
> is bad ergonomics, bad discoverability and bad API design. 
> `filterBidirectional` delenda est.

I agree with you that it probably should be bidirectional by 
default. I don't agree with making back lazy (but that is perhaps 
a separate topic). It probably should have a compile time flag to 
enable bidirectional iteration (on by default).


More information about the Digitalmars-d mailing list