Besides distributed objects, one of these annotations appears to be used by ARC. I came across the following description of cla going to the output parameter by writing back :
If the parameter is not an Objective-C parameter parameter labeled out , then *p is read, and the result is written to temporary primitive semantics.
This is due to methods such as - (BOOL)executeWithError:(out NSError **)error .
Ignoring the out keyword, ARC has the correct behavior for processing a reference object passing as __autoreleasing , so ARC treats the error parameter as of type NSError * __autoreleasing * . If you use a variable other than the other, ARC will add a temporary pass to the autoreleasing variable in the function (for consistency):
Source
NSError *error; [obj executeWithError:&error];
Pseudotransformed code
NSError * __strong error; NSError * __autoreleasing temp; temp = error; [obj executeWithError:&temp]; error = temp;
With the above code, the string temp = error would not be needed if we somehow knew that temp would never be counted. This is where the out annotation takes effect. In the cited description, if out absent, the compiler should add the line temp = error , but if it contains out , it can exclude the line and make the code a little smaller / faster. With out converted code becomes:
NSError * __strong error; NSError * __autoreleasing temp; [obj executeWithError:&temp]; error = temp;
Of course, if you are worried about binary size and speed, you should simply encode the following:
NSError * __autoreleasing error; [obj executeWithError:&error];
It is possible that these annotations are used elsewhere throughout the compiler and at run time, and may be used in other places in the future. Personally, I like to use out as a hint to other developers that I will not read the meaning.
Brian Nickel Sep 23 '13 at 22:49 2013-09-23 22:49
source share