3 ms·
Why?
by 1980phipsi 4y ago
Why?
- masklinn 4y agoI'd guess it's because that's what C++ does. Though it's unclear to me that C++-style iteration (where you increment a running pointer until you reach an EOI pointer) is much used in C.
- WalterBright 4y agoStoring two pointers into the same array is a memory safety problem. It's hard to implement a borrow checker when there are two live mutable pointers into the same memory object.
- int_19h 4y agoI would expect the borrow checker to treat a slice as a logical pointer to all elements that are addressable through it, regardless of how it's implemented under the hood.
- int_19h 4y agoThis pattern originated in C; C++ iterators were specifically designed to fit it when it was already established.