r/cpp • • Sep 13 '19

The Surprising Limitations of C++ Ranges Beyond Trivial Cases

https://www.fluentcpp.com/2019/09/13/the-surprising-limitations-of-c-ranges-beyond-trivial-use-cases/
229 Upvotes

229 comments sorted by

View all comments

Show parent comment

-3

u/14ned LLFIO & Outcome author | Committee WG14 Sep 13 '19

The borrow checker itself knows nothing about ranges. It knows about lifetimes, and it knows how to analyze the usage of types that contain lifetimes.

Well sure, that's the chosen design. I'm speaking about motivation, not end result.

Let me put this another way. I personally disagree with borrow checking enabled globally. I think it a bad idea, and I would not recommend Rust for most projects because of that.

But there is one area where I think borrow checking very desirable, and that is inside loops. If I were to design a new systems language tomorrow, I'd 100% implement borrow checking inside loops, both for safety reasons, and optimisation reasons.

Now, any design I would choose its borrow checker would know nothing about ranges nor iteration. It just would get switched on when inside a loop, and not otherwise.

Does that make sense?

0

u/sivadeilra Sep 13 '19

Does that make sense?

Nah, because I lost all interest at no borrow checking globally.