4 ms·
Allocations and copies are one of the things substructural typing formalizes. It's how E.g. Rust essentially eliminates implicit copies.
by AlotOfReading 9mo ago
Allocations and copies are one of the things substructural typing formalizes. It's how E.g. Rust essentially eliminates implicit copies.
- whatis991 9mo agoI think I've heard of Rust devs complaining about moves having implicit bitwise copies that were not optimized away.
- AlotOfReading 9mo agoTraits with Copy can do that, I'm just saying they're not really implicit copies because it's a core, visible part of the language that the developer can control on all of their own types.
- whatis991 9mo agoBut do bitwise copies when moving not also possibly incur that, even without Copy? If the optimizer doesn't optimize it away? Since movement can happen by copying bits and releasing the old bits, as long as there is no UnsafeCell in the type, or something along those lines? https://www.reddit.com/r/rust/comments/vo31dw/comment/ieao7vu/ https://www.reddit.com/r/rust/comments/vo31dw/comment/ieao7v...
- zozbot234 9mo agoAvoiding bitwise moves requires either costly indirection or else some sort of express place semantics where some program values are meant to be accessed in a fixed pattern such as stack-like access (most common) or perhaps other kinds, such as deque, sequence, tree etc. Substructural types can help model this but doing so correctly is not always easy.