|
|
|
|
|
by valenterry
1822 days ago
|
|
I see - but then you would still not have guaranteed local reasoning within the part of the code that modifies the vector. Is that really worth it? Also, creating the second vector should really look like "v2 = v.copy(x = x + 5); return v2.length". Or even just "return v.copy(x = x + 5).length". |
|
This is the same model that Rust takes too. It doesn't eliminate mutability, only controls it. The argument that "performance doesn't matter anymore because computers are so fast" is a bad one. Efficiency is efficiency, and immutability will always be less efficient.