digitalmars-d at puremagic.com
Wed May 14 02:47:55 PDT 2014
On Wednesday, 14 May 2014 at 06:00:33 UTC, Ola Fosheim Grøstad
> 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
>> any concrete implementation details such as whether .empty can
>> non-trivial initialization work. Properly-written range-based
>> 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
I wouldn't say never, because optimizers have become damn good. I
believe the additional overhead of lazy initialization is mostly
optimized away where it matters, i.e. inner loops, because the
compiler can see that the initialization has already been
performed in the first iteration. All it requires is unrolling
the first iteration of the loop and treating it specially.
But of course, this makes your conclusion even more true, because
More information about the Digitalmars-d