<div style="white-space:pre-wrap">I think there are some good points here. As a riff, though, I'd argue that Obj-C optional should *not* be renamed to elective or something else. Renaming, so far, has been for the purpose of providing first-class Swifty idioms for existing things. It makes moving between Swift-native code and legacy code more seamless and encourages increased use of what's being renamed. However, here we have something that we all agree isn't and cannot be a Swift idiom. Yes, it's true that the name clashes with Swift optional, but the very thing itself also clashes with how protocols requirements are intended to work in Swift. It *shouldn't* look like a first-class Swift concept.<br></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Apr 24, 2016 at 9:07 PM Erica Sadun via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Apr 24, 2016, at 3:28 PM, Chris Lattner via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br><div><div><br><blockquote type="cite">On Apr 22, 2016, at 8:02 PM, Douglas Gregor via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br><br><br><br>Sent from my iPhone<br><br><blockquote type="cite">On Apr 22, 2016, at 5:56 PM, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>> wrote:<br><br>Not an expert on Obj-C compatibility in Swift by any means, but this<br>reads like it's largely a change of nomenclature. To me, though,<br>`objcoptional` reads exceedingly poorly. Why not emphasize the Obj-C<br>compatibility angle by requiring the `@objc` attribute to precede each<br>use of `optional`? (In other words, effectively rename `optional` to<br>`@objc optional`.)<br></blockquote><br>That is a great idea. <br></blockquote><br>Doesn’t this have the same problem as the current (Swift 1/2) implementation? People will continue to believe that it is a bug that you must specify @objc.<br><br>-Chris<br></div></div></blockquote><br></div></div><div style="word-wrap:break-word"><div>I thought I'd throw a few ideas into the mix. I'm arriving late to the discussion. (I didn't expect the conversation to last this long.) I did take a quick look back through the thread but I may have missed some bits along the way. Apologies in advance for any redundancy:</div><div><br></div><div>* Optional requirement is an oxymoron. (This is a redux of my previous contribution to this topic but it's a good starting point.)</div><div><br></div><div>* Swift's "optional" protocol implementations are no such thing. They are default implementations that can be overridden. (Tangentially, why not introduce a required "override" keyword for conforming types that implement a version of a member introduced in protocol extensions? This would match the class approach and enhance safety and intent.)</div><div><br></div><div>* Swift already has an `Optional` type. Importing ObjC "optional" protocol requirements is therefore semantically problematic from a Swift development POV. I don't like either the "@objcoptional" or "@objc optional" solutions mentioned upthread. They overload "optional" syntactically and confuse semantics. I think the key words that better describe what's happening in, for example, a `UITableViewDelegate`, are "<i>discretionary</i>" or "<i>elective</i>" implementations. Swift has renamed lots of Objective C things (waves hi to <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0005-objective-c-name-translation.md" target="_blank">SE-0005</a>). Why not "optional"?</div><div><br></div><div>* I do *support* retaining `@objc` in some form and I believe it can be addressed in a way that does not appear to be a bug. "Optional protocol conformance" is a behavior that is external to the language. I do not believe would be voluntarily added to Swift should the topic arise. Therefore I find it insufficient to introduce attributes like `@elective` or `@discretionary` in order to satisfy non-native requirements. I would prefer to see the @objc attribute be extended to support these and any future Objective-C-specific behaviors: @objc(elective), @objc(importedProtocolSupport: elective), or whatever. While these are wordy, I assume like any other Swift attributes they can be placed on a line before the function declaration, and it would be instantly clear why they've been placed there, and they would not overlap with Swift semantics *or* expectations. I leave the color of the bikeshed as an exercise for the reader.</div></div><div style="word-wrap:break-word"><div><br></div><div>-- Erica</div><div><br></div></div>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>