<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Let’s see…</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">let name = plist[“name”].bridge() as String</div></blockquote><div class=""><br class=""></div>Not the worst, but definitely better than any of the alternatives below. Unfortunately, I think that “if” is out of the question, at least for Swift 3.<div class=""><br class=""></div><div class="">Jordan<br class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 23, 2016, at 20:21, Jed Lewison &lt;<a href="mailto:jed.lewison@icloud.com" class="">jed.lewison@icloud.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">If we could have extensions on AnyObject, a simple .bridge() would do the trick, right? (Assuming bridge was generic.) I think something along those lines was mentioned in the proposal.</span><br class=""><br class="">Sent from my iPhone</div><div class=""><br class="">On May 23, 2016, at 5:26 PM, Jordan Rose via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div class="">I am way late, but I share Brent’s concerns. I don’t think this addresses the very common case of “getting a String out of a heterogeneous dictionary”.</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class="">let name = plist[“name”] as! String</blockquote><div class=""><br class=""></div>becomes one of these:<div class=""><br class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class="">let name = plist[“name”] as! NSString as String</blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class="">let name = String(plist[“name”] as! NSString)</blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class="">let name = String(forceBridging: plist[“name”]) // not in the proposal</blockquote><div class=""><br class=""></div>none of which I’m particularly happy with.&nbsp;<br class=""><div class=""><br class=""></div><div class="">Jordan</div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On May 19, 2016, at 02:31, Brent Royal-Gordon via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><blockquote type="cite" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>* What is your evaluation of the proposal?<br class=""></blockquote><br class="">The review is technically over, but I don't believe a decision has been announced yet, so...<br class=""><br class="">I am generally in favor, but I have a serious concern about the readability of certain conversions with this change. To wit, conversions like these:<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>myArray as! [NSView]<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>myDictionary as! [String: NSView]<br class=""><br class="">Are about to become something more like these:<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>[NSView](forcedLazyBridging: myArray)<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>[String: NSView](forcedLazyBridging: myDictionary)<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span><br class="">Or these:<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>Array&lt;NSView&gt;(forcedLazyBridging: myArray)<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>Dictionary&lt;String, NSView&gt;(forcedLazyBridging: myDictionary)<br class=""><br class="">Either option is a significant regression in code readability compared to the status quo.<br class=""><br class="">It's enough to make me wonder if we shouldn't have special-cased conversion methods for NSArray, NSDictionary, and NSSet:<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>myArray.of(NSView)<span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>// returns [NSView]<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>myDictionary.of(NSView, for: String) <span class="Apple-tab-span" style="white-space:pre">        </span>// returns [String: NSView]<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>mySet.of(NSView)<span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">        </span>// returns Set&lt;NSView&gt;<br class=""><br class="">On the other hand, if you *don't* have to specify an element type, these aren't so bad:<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>Array(forcedLazyBridging: myArray)<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>Dictionary(forcedLazyBridging: myDictionary)<br class=""><br class="">And it gets even better if you use something a little saner than `forcedLazyBridging` for the label.<br class=""><br class=""><blockquote type="cite" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>* Is the problem being addressed significant enough to warrant a change to Swift?<br class=""></blockquote><br class="">Yes. Conversions are a mess, and it'll be nice to clean them up.<br class=""><br class=""><blockquote type="cite" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>* Does this proposal fit well with the feel and direction of Swift?<br class=""></blockquote><br class="">Yes.<br class=""><br class=""><blockquote type="cite" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>* If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?<br class=""></blockquote><br class="">Most languages I've used have had much simpler cast systems with nothing particularly close to Swift's bridging casts.<br class=""><br class=""><blockquote type="cite" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>* How much effort did you put into your review? A glance, a quick reading, or an in-depth study?<br class=""></blockquote><br class="">Quick reading.<br class=""><br class="">-- <br class="">Brent Royal-Gordon<br class="">Architechies<br class=""><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></div></blockquote></div><br class=""></div></div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></div></div></blockquote></div><br class=""></div></body></html>