[swift-evolution] Static Dispatch Pitfalls

Matthew Johnson matthew at anandabits.com
Sun May 22 10:31:23 CDT 2016



Sent from my iPad

> On May 22, 2016, at 8:39 AM, L. Mihalkovic <laurent.mihalkovic at gmail.com> wrote:
> 
> 
>> On May 22, 2016, at 3:15 PM, Matthew Johnson <matthew at anandabits.com> wrote:
>> 
>> 
>> 
>> Sent from my iPad
>> 
>>>> On May 22, 2016, at 1:49 AM, Vladimir.S via swift-evolution <swift-evolution at swift.org> wrote:
>>>> 
>>>> On 22.05.2016 3:01, L. Mihalkovic via swift-evolution wrote:
>>>> Read the proposal... I have an aversion to-go coffee cups that remind
>>>> people that hot coffee may burn them, and when my daughter was 4 we
>>>> explained to her why knives were to be handled with care, rather than
>>>> remove them all from her sight. IMHO the proposal evoques mandating
>>>> training wheels rather than letting people learn naturally from their
>>>> errors.
>>> 
>>> I can partially support this opinion. But we have a situation with protocol extension methods and static dispatches in which we need Swift's help on compilation stage. IMO Using your words, right now we just got knife in our hands *without* any explanation. Then we hurt ourselves, and *then* we know that such methods will be dispatched statically(and the rule of dispatch is quite non-obvious). This is another extreme like "remove all knives". We need some golden middle. Personally I believe the solution is in compiler warning and in some method to 'fix' this warning.
>> 
>> Why not just make it an error and require an annotation on the extension methods?
> 
> See   https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160516/018560.html
> And   https://github.com/lmihalkovic/swift-lang/tree/master/Dispatching.playground

That doesn't answer my question.  I don't like any of the suggestions you posted.  I think we should just leave the behavior as is (at least for now) and just require annotations on non-default methods in protocol extensions (making it an error to declare a non-default method without the annotation).



> 
> 
>>> 
>>> 
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution at swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>> 



More information about the swift-evolution mailing list