RFC: Adding Optional variants of == for collections to the std lib


(Paul Young) #1

I’d like to get a sense from contributors to the standard library if they feel that the functionality in https://github.com/paulyoung/OptionalEquatableCollection has a place there.

The project provides Optional variants of the existing implementations of the "equal to” operator (==) for Array, Dictionary, and Set.

My question is more concerned with the overall concept as opposed to my particular implementation.

Thanks.


(Martin Kühl) #2

Wouldn’t this be solved automatically if collections of Equatable
could conform to Equatable themselves?
I.e. if this were valid

    extension Array: Equatable where Element: Equatable

then we wouldn’t need more special cases for (combinations of)
containers of Equatable elements, like the collection types currently
are.

(see also rdar://23433955)

Martin

···

On 5 December 2015 at 16:38, Paul Young <paulyoungonline@gmail.com> wrote:

I’d like to get a sense from contributors to the standard library if they feel that the functionality in https://github.com/paulyoung/OptionalEquatableCollection has a place there.

The project provides Optional variants of the existing implementations of the "equal to” operator (==) for Array, Dictionary, and Set.

My question is more concerned with the overall concept as opposed to my particular implementation.


(John McCall) #3

I’d like to get a sense from contributors to the standard library if they feel that the functionality in https://github.com/paulyoung/OptionalEquatableCollection has a place there.

The project provides Optional variants of the existing implementations of the "equal to” operator (==) for Array, Dictionary, and Set.

My question is more concerned with the overall concept as opposed to my particular implementation.

Wouldn’t this be solved automatically if collections of Equatable
could conform to Equatable themselves?
I.e. if this were valid

   extension Array: Equatable where Element: Equatable

then we wouldn’t need more special cases for (combinations of)
containers of Equatable elements, like the collection types currently
are.

Yes. This is an obvious limitation of the current system that we are eager to fix. Unfortunately, it is blocked by deficiencies at several levels, most visibly (to us, at least) at the IRGen / metadata layer. Addressing those is a priority for many reasons, but specifically unblocking this feature is one of them.

John.

···

On Dec 5, 2015, at 12:39 PM, Martin Kühl via swift-dev <swift-dev@swift.org> wrote:
On 5 December 2015 at 16:38, Paul Young <paulyoungonline@gmail.com> wrote:

(see also rdar://23433955)

Martin
_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev