Re:Copying data is wasteful, mutating data is dangerous
by pwm on Thursday January 09, 2020 @08:03PM
(#22007585)
Exactly. The only problem is that you need a language with a sufficiently powerful type system that can express both phantom and existential types.
Re:Copying data is wasteful, mutating data is dangerous
by chii on Thursday January 09, 2020 @11:34PM
(#22008323)
> The only problem is that you need a language with a sufficiently powerful type system
why is that a problem?
https://wiki.haskell.org/Monad/ST
It allows you mutate arrays and other stuff "on the inside" like this article suggests, but it's also able to wrap up the operation so it appears pure from the outside, so the caller doesn't have to guess or rely on naming conventions to figure out the mutability.
It's your choice on whether you want to do the copy on the way in ('thawing'), on the way out ('freezing'), or both, by using the 'in-place' variants of thaw and freeze.