Mixins would be a great addition instead of having to define a protocol and then extending it
···
Sent from my iPhone
Mixins would be a great addition instead of having to define a protocol and then extending it
Sent from my iPhone
Mixins are a vague term. What exactly do you propose?
-Joe
On Dec 23, 2015, at 11:54 AM, James Campbell via swift-evolution <swift-evolution@swift.org> wrote:
Mixins would be a great addition instead of having to define a protocol and then extending it
Correct, there is just a lot of infrastructure work blocking it from happening at the moment, not lack of desire.
-Chris
On Dec 23, 2015, at 11:57 AM, Stephen Celis via swift-evolution <swift-evolution@swift.org> wrote:
I remember reading another thread (the associated/typealias renaming discussion) where an Apple engineer wrote that this limitation is temporary and that functions should be definable directly in a protocol. If that's the case, this may just be a bug and not have to go through evolution.
Stephen
On Dec 23, 2015, at 2:54 PM, James Campbell via swift-evolution <swift-evolution@swift.org> wrote:
Mixins would be a great addition instead of having to define a protocol and then extending it
Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution
I obviously don't know what the original poster intended but the most common definitions I have seen are:
Trait: Protocols with default implementations for some method requirements.
Mixin: Traits with stored properties.
Sent from my iPhone
On Dec 23, 2015, at 1:57 PM, Joe Groff via swift-evolution <swift-evolution@swift.org> wrote:
On Dec 23, 2015, at 11:54 AM, James Campbell via swift-evolution <swift-evolution@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
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution
I remember reading another thread (the associated/typealias renaming discussion) where an Apple engineer wrote that this limitation is temporary and that functions should be definable directly in a protocol. If that's the case, this may just be a bug and not have to go through evolution.
Stephen
On Dec 23, 2015, at 2:54 PM, James Campbell via swift-evolution <swift-evolution@swift.org> wrote:
Mixins would be a great addition instead of having to define a protocol and then extending it
Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution
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@apple.com> wrote:
On Dec 23, 2015, at 11:54 AM, James Campbell via swift-evolution <swift-evolution@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
We should get this as a proposal in. That case so it doesn't slip off the radar if that is the case
Sent from my iPhone
On 23 Dec 2015, at 19:57, Stephen Celis <stephen.celis@gmail.com> wrote:
I remember reading another thread (the associated/typealias renaming discussion) where an Apple engineer wrote that this limitation is temporary and that functions should be definable directly in a protocol. If that's the case, this may just be a bug and not have to go through evolution.
Stephen
On Dec 23, 2015, at 2:54 PM, James Campbell via swift-evolution <swift-evolution@swift.org> wrote:
Mixins would be a great addition instead of having to define a protocol and then extending it
Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution
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
On Dec 23, 2015, at 12:03 PM, James Campbell <james@supmenow.com> wrote:
You can search https://bugs.swift.org and see if a bug has already been filed. If not, file one :)
Stephen
On Dec 23, 2015, at 3:06 PM, James Campbell <james@supmenow.com> wrote:
We should get this as a proposal in. That case so it doesn't slip off the radar if that is the case
Sent from my iPhone
On 23 Dec 2015, at 19:57, Stephen Celis <stephen.celis@gmail.com> wrote:
I remember reading another thread (the associated/typealias renaming discussion) where an Apple engineer wrote that this limitation is temporary and that functions should be definable directly in a protocol. If that's the case, this may just be a bug and not have to go through evolution.
Stephen
On Dec 23, 2015, at 2:54 PM, James Campbell via swift-evolution <swift-evolution@swift.org> wrote:
Mixins would be a great addition instead of having to define a protocol and then extending it
Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution