3 ms·
Wait what issue are you referring to? My version absolutely works, it just falls back to making one copy a lot. In my version the callee can absolutely make a
by mort96 6y ago
Wait what issue are you referring to? My version absolutely works, it just falls back to making one copy a lot.
In my version the callee can absolutely make a copy of only the modified fields if the function A) modifies some fields but not others and B) doesn't do anything which demands a full copy.
Anyways, discussion on the intent of the article isn't super productive, I wrote a reply to https://news.ycombinator.com/item?id=27091726 https://news.ycombinator.com/item?id=27091726 which asks the author what their intention was.
- Negitivefrags 6y agoSorry, you are correct. I was thinking about the post at the top of this chain that wasn't actually made by you.
- a1369209993 6y ago> My version absolutely works, Consider: void other_thread(struct large* l) { struct large new_l = { ... }; *l = new_l; } void do_other_thing() { struct large l = { ... }; thread_t t = start_thread(other_thread,&l); foo1(l); wait_for_thread(t); } Not only can `foo1` never avoid making a copy (because it can't assume it's unknown caller is not this perverse), it can't even make a copy safely unless its caller allocates a new `struct large` for it to copy from. (And the caller does not, in general, know that `start_thread` (or `process_thingy_maybe_concurrently^W^W`) starts a thread with the aliased `&l`, so it would have to make such copies on any substantially escaping alias just to be sure, at which point you're back to the original proposal.) The pass-by-non-mutatably-aliased-reference ABI seems terrible IMO, but it at least allows the callee to decide whether to copy using only information that's actually present in the callee.