4 ms·
Because it leads to hard to understand code. If N unrelated (or loosely related) things can mutate the same object, then you get a O(x^N) explosion of potentia
by pkolaczk 6y ago
Because it leads to hard to understand code.
If N unrelated (or loosely related) things can mutate the same object, then you get a O(x^N) explosion of potential mutation orders and in order to understand that, you need to understand all the (sometimes complex) time-relationships between these N objects. This gets even much worse when some of these objects are also pointed from M other objects...
On the flip side, in case of using a simple unique_ptr (or a similar concept), this trivially reduces to a single sequence of modifications.
- verdagon 6y agoDont we in Rust still conceptually modify the vector multiple times, just through different means (usually a generational index or something)?