[swift-evolution] [Review] SE-0070: Make Optional Requirements Objective-C only
Andrew Bennett
cacoyi at gmail.com
Wed Apr 27 17:29:56 CDT 2016
Hi Charles,
My initial idea just had a fatalError, without a throw. It's better IMO,
but less Swift-y. It's not obvious from the Swift protocol definition that
this could happen. I'm not sure if it's possible for the extension method
to have @noreturn or similar on it.
On Thursday, 28 April 2016, Charles Srstka <cocoadev at charlessoft.com> wrote:
> On Apr 27, 2016, at 9:30 AM, Andrew Bennett via swift-evolution <
> swift-evolution at swift.org
> <javascript:_e(%7B%7D,'cvml','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/20160428/b356bbe7/attachment.html>
More information about the swift-evolution
mailing list