[swift-evolution] [Review] SE-0070: Make Optional Requirements Objective-C only
Charles Srstka
cocoadev at charlessoft.com
Wed Apr 27 10:37:49 CDT 2016
> On Apr 27, 2016, at 9:30 AM, Andrew Bennett via swift-evolution <swift-evolution at swift.org> wrote:
>
> Sorry if this has been discussed, but have you considered dropping optional entirely, making it throw, and a default implementation that throws a selector not found exception?
>
> This is approximately what you would expect using it in objc. I don't think it has the complexity discussed in the proposals alternatives for other call site issues.
>
> If it throws you can call with "try?" to get similar functionality in most cases.
>
> This assumes that respondsToSelector doesn't pick up the Swift default implementation.
Is there any case where you’d actually want to display a runtime error as a result of a delegate not implementing an optional method, though? Even setting aside that the method’s supposed to be optional, leaving out a needed delegate method seems more like a programmer error than a runtime error.
Charles
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160427/13040a75/attachment.html>
More information about the swift-evolution
mailing list