> On Dec 23, 2015, at 12:03 PM, James Campbell <[email protected]> wrote:
> 
> So Mixins are a way of opting in to shared behaviour. 
> 
> Think of it as having default implementations for protocols 
> 
> So you could have code that handles pagination rather than implement it 
> multiple times you mix it into multiple classes. Ruby and JavaScript support 
> these
> 
> But in swift to do this you  have to define a protocol, make your class 
> extend from it and then extend the protocol with some methods 

It sounds to me like you're asking mostly for different syntax for what 
protocol extensions already achieve. It's a limitation of the language today 
that you need to provide default implementations outside the protocol in an 
extension, which is an unfortunate bit of boilerplate, but we hope to improve 
that. Any sort of useful mixin-like thing still needs to be based on a common 
protocol that types adopting the mixin must conform to, so I can't see it being 
usefully different from protocols with default implementations.

> The downside is this isn't a true mixin implementation as typically Mixins 
> allow you to specific properties. 

There's a proposal in another thread to remove this restriction. You might 
contribute to that discussion if you haven't already.

-Joe
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to