4 ms·
It still doesn't sit right with me that they still don't offer an option to enable deep copying the results. Using it with a function that returns a mutable obj
by curiousgal 3y ago
It still doesn't sit right with me that they still don't offer an option to enable deep copying the results. Using it with a function that returns a mutable object means that the "cached" value can actually be modified.
- geysersam 3y agoThat depends on the semantics. If the function returns the Person object with a particular name (obtained from an expensive dB query) then you want the mutated Person returned, not the now stale value that was returned on the previous call to the function.
- o11c 3y agoBecause deep copying is always a bug. If your type semantically requires a deep copy, implement plain copy such that it actually does a deep copy.