[swift-evolution] Pre-proposal: Convert reference params to tuples
cocoadev at charlessoft.com
Sat Jan 9 21:22:09 CST 2016
> On Jan 9, 2016, at 7:52 PM, Kenny Leung via swift-evolution <swift-evolution at swift.org> wrote:
> How would this work on the stack? I imagine returning a value in a tuple would make it a completely different location on the stack than where the original parameter would be where the ObjC side would be expecting it. This would break the calling convention.
My thinking is that the Swift compiler would create a temporary variable, then pass a pointer to that to the Objective-C method. After the method is complete, the temporary variable would be copied into the tuple, and converted as needed.
You pretty much have to do it this way, because of the disparities between the types on the Swift side and the Objective-C side: Bool vs. BOOL, String, vs. NSString, etc. To ensure a good user experience, these things all need to be translated to their Swift counterparts before returning them.
More information about the swift-evolution