Re:Copying data is wasteful, mutating data is dangerous
by tene on Thursday January 09, 2020 @07:59PM
(#22007569)
You may be interested in the `im` crate for Rust, which implements efficient copy-on-write structural sharing, falling back to in-place mutation when there are no other outstanding references.
Re:Copying data is wasteful, mutating data is dangerous
by vmchale on Thursday January 09, 2020 @02:03PM
(#22004303)
> It seems like further advances in this space either require giving the compiler a better understanding of what is "actually" shared
In the context of arrays, it helps when programmers use higher-order combinators/functions, e.g. maps.
There is a mutable way to do a map, and an immutable way, and which should be used in the compiled program depends on analysis of where the variable is used.
Mutability is always (at least as current computer architectures are concerned) going to be faster in a general sense.