range behaviour
via Digitalmars-d
digitalmars-d at puremagic.com
Tue May 13 23:00:31 PDT 2014
On Tuesday, 13 May 2014 at 17:32:21 UTC, H. S. Teoh via
Digitalmars-d wrote:
> Lastly, since the range API is an *abstraction*, it should not
> dictate
> any concrete implementation details such as whether .empty can
> do
> non-trivial initialization work. Properly-written range-based
> code
> should be able to handle all possible implementations of the
> range API,
> including those that do non-trivial work in .empty.
An API is a "user" interface. It should be intuitive.
Besides, D ranges will never perform as well as an optimized
explicit loop, so you might as well aim for usability over speed.
I learned this over 15 years ago when I was fed up with STL
begin/end and implemented my own inlined iterators that work like
D ranges ( for a scanline renderer ).
More information about the Digitalmars-d
mailing list