[swift-evolution] [Proposal] Separate protocols and interfaces
antonyzhilin at gmail.com
Sun Jan 3 12:25:12 CST 2016
The problem with syntax of "existential protocol" and "protocol" is that
the first should actually be default, and easier to write.
We should prefer static to dynamic. It is as if "structs" had to be
declared as "static class", or "let" variables as "const var". Shorter
keywords should be used for enforcing good practices.
Additionally, 95% of standard library protocols are actually "existential
protocols", or "protocols" in my notation.
Next, I don't know any language which has "existential" keyword. Moreover,
"existential types" in Haskell mean means (roughly) "type that can hold
value of any instance of class with type erasure", and that is exactly what
an interface is in Swift. So, I think that if we will add "existential"
keyword, we would add it the other way: for dynamically dispatched types.
Some other suggestions (imagine a table):
statically dispatched - dynamically dispatched
protocol - interface
protocol - dynamic protocol
protocol - existential protocol
static protocol - dynamic protocol
trait - protocol
trait - interface
I also personally like the "trait - protocol" naming. Traits are used to be
statically dispatched things in other languages, and protocols are
dynamically dispatched things from Objective-C. Actually, I'm satisfied
with any pair unless dynamic protocols get shorter names.
P.S. I'll correct that Self issue, thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution