The “Objective-C for Java Programmers, Part 1” intro by David Chisnall states that
Unlike objects, which are always passed by reference, structures are
commonly passed by value.
I am very new to Objective-C (coming from C++) and so I am having trouble understanding this. In C++, I could pass a structure either by a pointer or by reference, but never by value (probably because it is very inefficient).
How does Objective-C accomplish this? Does it really push all structure members, one by one, in a stack-like manner?
What happens if the structure is made of large/complex objects?
Yes it makes a copy of the whole structure and this one is passed to the calling function, and any modification made won’t affect the original one. And the disadvantage is of course because it is slow, but also consumes twice space.