[swift-evolution] [Pitch] Reducing the bridging magic in dynamic casts

Chris Lattner clattner at apple.com
Mon May 2 16:45:25 CDT 2016

On Apr 29, 2016, at 3:00 PM, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
> I’d like to propose the following changes:
> Dynamic casts as?, as! and is should no longer perform bridging conversions between value types and Cocoa classes.
> Coercion syntax as should no longer be used to explicitly force certain bridging conversions.
> To replace this functionality, we should add initializers to bridged value types and classes that perform the value-preserving bridging operations.
+1.  I think that this will lead to a much cleaner and more predictable set of rules.  It will probably also define away a ton of bugs in the compiler and runtime.

> NSError bridging can also be extracted from the runtime, and the same functionality exposed as a factory initializer on NSError:

I think that this proposal is overall really great, but what does it do to the “catch let x as NSError” pattern?  What is the replacement?  If the result is ugly, we may have to subset out NSError out of this pass, and handle it specifically with improvements to the error bridging story.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160502/2948d63e/attachment.html>

More information about the swift-evolution mailing list