On Friday, 21 January 2022 at 17:25:20 UTC, Ali Çehreli wrote:

Ouch! I tried the following code, my laptop got very hot, it's been centuries, and it's still running! :p

:)

```d
   size_t length() inout {
     auto len = 1 + (last - first) / step;
     return cast(size_t)len;
   }
```
Does that not return 1 for an empty range?

Yes, but it will never return an empty range:

```d
  enum e = 1;
  auto o = inclusiveRange(e, e); // only one element
  assert(!o.empty);
  assert(o.length == e);
  assert(o.equal([e]));
```

Additionally, just because we *provide* a step, now we *require* division from all types (making it very cumbersome for user-defined types).

I don't quite understand what you mean?

Salih

Reply via email to