3 ms·
> With half open ranges, the length of the range is the end minus the beginning, which is nice. But I already know from real life that if there's maintanence i
by sundarurfriend 3y ago
> With half open ranges, the length of the range is the end minus the beginning, which is nice.
But I already know from real life that if there's maintanence in blocks 5 to 15, that's eleven blocks under maintanence. With half-open ranges, it once again introduces confusion and makes things unintuitive.
We can each find countless examples where each style comes out better, for eg `1:N` most often expresses the intent better than `range(N+1)`. I find people who prefer half-open ranges to be weird and incomprehensible, you probably find my preferences the same, I just don't like the categorical statement often made in this regard that one is inherently and universally superior to the other.
- bobbylarrybobby 3y agoYes, range(n+1) is bad. I hate python as well. You want something like Rust’s m..n and m..=n to have the choice. Anyway, if you have half open ranges, it's trivial to get a closed range (add one to the right endpoint), but going the other direction is not so simple.
- Iwan-Zotow 3y agoJulia ranges are not composable, period In Python, C/C++ and its descendant [0...N)=[0...N/2)+[N/2...N)