Well, if the object were to be stored inline, then whenever you access it you do need to copy it. Of course in some cases that can be optimized out and if you are just dealing with an object with 2 field copying isn’t going to matter too much but that’s not always the case, i.e.
Well, sort of, but both the statement and the logic are wrong.
For a start, non-isbits are NOT required to be heap-allocated. They are only required to be heap allocated at interfaces. In general, such interfaces includes fields, arrays and function call arguments and return values. Note that is exactly what this thread is about i.e. the correct version of that statement is related as in it is exactly describing this phenomena but it’s not the reason.
is wrong. Storing it inline will not require any more allocation for structs that has references as fields.
What IS true, OTOH, is that there must be a single convention as for if a type is passed by copying or reference in fields and as argument (including array and return value). And THIS is exactly because otherwise it will be required to make allocation.
Bottom line is, such change in the language will not require more heap allocation. It will only require more copying and that’s the performance trade-off.
It is completely intentional. It’s a long-standing performance trade-off.