In general, Swift will need a way to point to a generic type without a
particular specialization. Currently, you can't do this:
class APICall<T> { }
class CombinedCall: APICall<Bool> {
var calls: [APICall] // Error - no specialization
}
I've been currently working around this by:
class APICallBase {} // No generics
class APICall<T>: APICallBase {}
class CombinedCall: APICall<Bool> {
var calls: [APICallBase]
}
But it's definitely a pain to work with.
As asked by the core team several times now, we should defer any discussion on
additional features until August.
> On Jul 18, 2016, at 9:04 AM, Adrian Zubarev via swift-evolution
> <[email protected]> wrote:
>
> This is something additional, but I’m curios about how the community feels
> about it.
>
> I recently come across the issue where conforming to Hashable wasn’t enough
> to thecke if two instances of the same generic type were equal.
>
> I had additionally provide myself the != function.
>
> public func !=<T, U>(lhs: SomeTypeName<T>, rhs: SomeTypeName<U>) -> Bool {
> return lhs.hashValue != rhs.hashValue
> }
> I wondered if Swift can ever get generic specialization like this:
>
> public func !=<T : Hashable, U, V>(lhs: T<U>, rhs: T<V>) -> Bool {
> return !(lhs.hashValue == rhs.hashValue)
> }
> This function in stdlib would fill the gap. Or we need an extra protocol
> GenericHashable which includes !=.
>
>
>
>
> --
> Adrian Zubarev
> Sent with Airmail
>
> _______________________________________________
> swift-evolution mailing list
> [email protected] <mailto:[email protected]>
> https://lists.swift.org/mailman/listinfo/swift-evolution
> <https://lists.swift.org/mailman/listinfo/swift-evolution>
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution