[swift-evolution] Mixins
James Campbell
james at supmenow.com
Wed Dec 23 14:03:20 CST 2015
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
The downside is this isn't a true mixin implementation as typically Mixins allow you to specific properties.
So Mixins are closer to extensions with support for properties which you can include to multiple classes
Sent from my iPhone
> On 23 Dec 2015, at 19:57, Joe Groff <jgroff at apple.com> wrote:
>
>
>> On Dec 23, 2015, at 11:54 AM, James Campbell via swift-evolution <swift-evolution at swift.org> wrote:
>>
>> Mixins would be a great addition instead of having to define a protocol and then extending it
>>
>
> Mixins are a vague term. What exactly do you propose?
>
> -Joe
More information about the swift-evolution
mailing list