4 ms·
The expectation is the compiler does what you tell it? If you want pointers in your map, you can do that too.
by tedunangst 3y ago
The expectation is the compiler does what you tell it? If you want pointers in your map, you can do that too.
- Arnavion 3y agoThey're asking that, if the programmer wants the map to store expensivetocopyvalue semantically but also doesn't want to have iteration generate expensive copies, does the programmer have to change the map to store *expensivetocopyvalue instead? Anyway I believe the answer is that expensivetocopyvalue is not a type that exists in golang, because golang's "copy" operation is always a simple bitwise copy ala C struct copy / Rust's Copy trait, not like C++ copy ctor / Rust's Clone trait that can be arbitrarily expensive.
- morelisp 3y agoIn Go, `expensivetocopyvalue` can still be achieved via an enormous (e.g. multi-KB/MB) structure (which is most literally expensive to copy) or something containing a lot of pointers (which is not really expensive to copy but will start to pressure the GC).
- deleted 3y ago[deleted]