Hi Trevör, What you’re asking for has been discussed extensively and a very thorough proposal was drafted by Austin Zheng: https://github.com/austinzheng/swift-evolution/blob/az-existentials/proposals/XXXX-enhanced-existentials.md
This is not something that is likely to make it into Swift 4 but is a feature with a lot of community demand so it is likely to be added eventually. Matthew > On Feb 10, 2017, at 10:46 AM, Trevör ANNE DENISE via swift-users > <swift-users@swift.org> wrote: > > Hello everyone ! > > I am currently writing a project where I would like to do something similar > to this: > > protocol ProtocolA { > associatedtype U > var someVariable : U { get set } > func someFunction(_ x:U) -> U > } > > class SomeClass<T> { > var someProperty : ProtocolA where ProtocolA.U == T > } > > But this isn't possible so I had to implement it as a generic class: > class NewClass<U> { ... } > > And now I am using it like this: > class SomeClass<T> { > var someProperty: NewClass<T> > } > > The issue here is that protocols aren't used any more with this approach, and > in my case there is no "default" implementation of myFunction, so protocols > where really useful!! > > Is there a better way to do that in the current Swift version? > > Today, I came across the proposal SE-0142 (Permit where clauses to constrain > associated types), but this only seems to apply inside of protocols, what is > your opinion about having similar mechanisms in classes and structs ? > > Thank you! > > Trevör > _______________________________________________ > swift-users mailing list > swift-users@swift.org > https://lists.swift.org/mailman/listinfo/swift-users
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users