[swift-users] Generic inheritance with where clause

2017-08-29 Thread Nikita Leonov via swift-users
Hello everyone,

I am looking a way to express something similar to the following code in
Swift terms:
protocol AnyViewModelInput {}
protocol AnyViewModel: ViewModelInput where ViewModelInput:
AnyViewModelInput {
var input: ViewModelInput { get }
}

Is it possible in current Swift? Will it be possible if generic
manifesto will be implemented in full? Also if you know how to express a
similar idea in any other language, I would love to see examples. How does
such construct is named in other languages?

Thank in advance,
Nikita
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Generic inheritance with where clause

2017-08-29 Thread Nikita Leonov via swift-users
Hello everyone,

I am looking a way to express something similar to the following code in
Swift terms:
protocol AnyViewModelInput {}
protocol AnyViewModel: ViewModelInput where ViewModelInput:
AnyViewModelInput {
var input: ViewModelInput { get }
}

Such construct supposed to avoid code duplications as follows and reuse
code for splitting view models its inputs etc:
protocol FooViewModelInput {
var foo: Int { get set }
}

protocol FooViewModelProtocol: FooViewModelInput {
var input: FooViewModelInput { get }
}

final class FooViewModel: FooViewModelProtocol {
var input: FooViewModelInput {
return self
}
var foo = 0
}

Is it possible in current Swift? Will it be possible if generic
manifesto will be implemented in full? Also if you know how to express a
similar idea in any other language, I would love to see examples. How does
such construct is named in other languages?

Thank in advance,
Nikita
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users