[swift-evolution] Notes from Swift core team 2016-04-20 design discussion
Thorsten Seitz
tseitz42 at icloud.com
Sat Apr 23 15:09:39 CDT 2016
Ah, yes, you are right, I didn’t think of configuring delegates when the delegate ist set.
-Thorsten
> Am 22.04.2016 um 19:04 schrieb David Waite <david at alkaline-solutions.com>:
>
> Sure, but I personally want to configure delegates early, when the delegate is set.
>
> It may be inappropriate to send a synthetic message through (e.g. give me the table row height for arbitrary index -1 so I can detect if you have overridden behavior)
>
> A default implementation may help the caller, but some API do consider a non-default implementation to be a flag in itself.
>
> I don’t think you can meet current objective-c usage and meaning of optional protocols by collapsing the flag into default method behavior. This would cause problems when porting the objective-c caller of the delegate interface to swift.
>
> -DW
>
>> On Apr 22, 2016, at 10:01 AM, Thorsten Seitz <tseitz42 at icloud.com <mailto:tseitz42 at icloud.com>> wrote:
>>
>> We could require optional methods which would return T to instead return OptionalResult<T> which is essentially an enum with values 'unimplemented' and 'implemented(T)', i.e. essentially the same as Optional but as a separate type to avoid confusion when the real result would be 'T?'.
>>
>> Default implementations would answer 'unimplemented'.
>>
>> This would require the caller to handle the unimplemented default case explicitly.
>>
>> -Thorsten
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160423/ba2d106d/attachment.html>
More information about the swift-evolution
mailing list