[swift-evolution] [Review] SE-0058: Allow Swift types to provide custom Objective-C representations
xenadu at gmail.com
Wed Apr 6 12:22:00 CDT 2016
> On Apr 5, 2016, at 5:57 PM, Kevin Lundberg via swift-evolution <swift-evolution at swift.org> wrote:
> Generally I'm +1 on this, but I do have a concern. It's not made explicit in the proposal, but I presume that this is meant to only be available on Darwin, and not Linux or other platforms that don't have swift using the Objective-C runtime? (Please correct me if I am mistaken.)
> I ask because of the swift-corelibs-foundation project; Presumably once that is complete for Swift 3, code that makes use of this type bridging should be able to be run cross-platform. For example:
> var a = [AnyObject]()
> (a as NSArray).addObject(NSObject()) // should this work on all platforms?
> swift-corelibs-foundation uses its own protocol named _ObjectTypeBridgeable (defined here: https://github.com/apple/swift-corelibs-foundation/blob/338f4bf3a89c75a0420b49f5701466e106af02b5/Foundation/NSSwiftRuntime.swift#L205 <https://github.com/apple/swift-corelibs-foundation/blob/338f4bf3a89c75a0420b49f5701466e106af02b5/Foundation/NSSwiftRuntime.swift#L205>) to simulate what happens today on Darwin platforms, but there is no language support for it so API consumers must explicitly call its bridging methods. It would be great if corelibs-foundation (and any code designed to work on Linux) could take advantage of this proposal to provide the language support, and if the proposal as written is not intended to have an effect on Linux at all, then I would suggest we modify it so that the resulting implementation is not tied to Objective-C and Darwin only.
The original intent was to be available on platforms that have an Objective-C runtime (Darwin only at the moment, I guess in theory Windows if someone were determined enough).
You bring up a good point; there is nothing in the protocol that absolutely requires Objective-C, only that it requires AnyObject be the root object type.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution