<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><blockquote type="cite" class="">Method invocation syntax does not inherently mean "dynamic dispatch" any more than function syntax does.<br class=""></blockquote><div class=""><br class=""></div><div class="">In languages now in widespread use — Java, Ruby, Javascript, C#, what I know of Python — that is _precisely_ what it means. In all those languages, as far as I know:</div><div class=""><br class=""></div><div class=""><ul class="MailOutline"><li class=""><b class="">all</b> uses of the dot invocation syntax either use dynamic dispatch, or have something on the left whose compile-time and runtime types are identical; and</li><li class=""><b class="">all</b>&nbsp;instances of dynamic dispatch in the language either use the dot invocation syntax, or have and implicit&nbsp;“self.” / “this.” &nbsp;that uses it.</li></ul></div><div class=""><br class=""></div><div class="">In short, programmers are likely to bring to Swift the assumption that dot invocation = dynamic dispatch.</div><div class=""><br class=""></div><div class="">Our difference of perspective on this single point [rimshot] is probably the source of our larger disagreement on this entire thread.</div><div class=""><br class=""></div><div class="">Cheers, P</div><div class=""><br class=""></div><br class=""><blockquote type="cite" class="">On Dec 10, 2015, at 6:31 PM, Kevin Ballard via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class="">On Thu, Dec 10, 2015, at 02:24 AM, Brent Royal-Gordon wrote:<br class=""><blockquote type="cite" class="">Swift loves to dispatch things statically and does so wherever possible. In some cases—such as value types not having&nbsp;inheritance—language features are clearly designed the way they are specifically to allow them to be statically dispatched.&nbsp;But Swift never uses static dispatch where dynamic dispatch would have given a different result. This contrasts with, for&nbsp;instance, a non-virtual C++ method’s behavior of “ha ha ha, I’m just going to ignore your override for speed." You could write&nbsp;a Swift compiler which dispatched everything dynamically, and you would never see any difference in semantics.<br class=""></blockquote><br class="">Yes it does. When message dispatch is done using the obj-c runtime, the compiler is free to omit the message send and use&nbsp;static dispatch if it believes it knows the concrete type of the receiver. This normally behaves the same, because dynamic&nbsp;dispatch with a known receiver type and static dispatch are the same, except if the method is dynamically replaced using the&nbsp;obj-c runtime methods, the static dispatch will not invoke the dynamically overridden method. The most common way you see&nbsp;this is with KVO. If you try and KVO an @objc property on a Swift object, it may work sometimes and may not work at other&nbsp;times, depending on when the compiler believes it can safely use static dispatch. This is why Swift has a whole keyword called&nbsp;`dynamic` whose job is to say "no really, use dynamic dispatch for every single access to this method/property, I don't care&nbsp;that you know for a fact it's a Foo and not a subclass, just trust me on this".<br class=""><br class="">More generally, I don't see there being any real difference between<br class=""><br class="">extension Proto {<br class="">&nbsp; &nbsp;func someMethodNotDefinedInTheProto()<br class="">}<br class=""><br class="">and saying<br class=""><br class="">func someFuncThatUsesTheProto&lt;T: Proto&gt;(x: T)<br class=""><br class="">except that one is invoked using method syntax and one is invoked using function syntax. Method invocation syntax does not&nbsp;inherently mean "dynamic dispatch" any more than function syntax does.<br class=""><br class="">-Kevin Ballard<br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></blockquote><br class=""></body></html>