[swigt-evolution] [Pitch] Make NSOrderedSet behave like any other collections from Foundation


(Psycho Hedgehog) #1

Hello everyone,

Unlike its companion collections like NSArray, NSDictionary, and NSSet, NSOrdered is still a class rather than a struct and has a subclass that is still NSMutableOrderedSet. This should probably receive the same treatment as the other classes, namely:

- Use value semantic
- Use generics
- Keep the original NSOrderedSet class and its subclass NSMutableOrderedSet and bridge the two.

struct OrderedSet<Element : Hashable> : SetAlgebra, Hashable, Collection, ArrayLiteralConvertible

This would add an ordered set type to Swift and fits nicely into the existing set of collections and classes moved from Foundation.


(Brent Royal-Gordon) #2

Unlike its companion collections like NSArray, NSDictionary, and NSSet, NSOrdered is still a class rather than a struct and has a subclass that is still NSMutableOrderedSet. This should probably receive the same treatment as the other classes

Swift Evolution proposal SE-0069 "Mutability and Foundation Value Types" notes at the bottom <https://github.com/apple/swift-evolution/blob/master/proposals/0069-swift-mutability-for-foundation.md>:

The following classes were considered and rejected or deferred for the described reasons:

  • OrderedSet, CountedSet: We will consider these types in a future proposal.

So sit tight—the Foundation team is already thinking about this. (That doesn't mean you'll necessarily see it this year, though.)

···

--
Brent Royal-Gordon
Architechies


(Tony Parker) #3

Hi Remy, Brent,

We’re thinking about it but there are no plans for Swift 3 in this respect (although I think we’re going to keep the NS prefix on these types).

One of the complexities with this type is its performance characteristics, especially when used with CoreData (the reason it was introduced). CoreData relies a lot on proxying for performance reasons, but there is currently an impedance mismatch between that behavior and Swift’s focus on static typing.

- Tony

···

On Jun 17, 2016, at 10:43 AM, Brent Royal-Gordon via swift-evolution <swift-evolution@swift.org> wrote:

Unlike its companion collections like NSArray, NSDictionary, and NSSet, NSOrdered is still a class rather than a struct and has a subclass that is still NSMutableOrderedSet. This should probably receive the same treatment as the other classes

Swift Evolution proposal SE-0069 "Mutability and Foundation Value Types" notes at the bottom <https://github.com/apple/swift-evolution/blob/master/proposals/0069-swift-mutability-for-foundation.md>:

The following classes were considered and rejected or deferred for the described reasons:

  • OrderedSet, CountedSet: We will consider these types in a future proposal.

So sit tight—the Foundation team is already thinking about this. (That doesn't mean you'll necessarily see it this year, though.)

--
Brent Royal-Gordon
Architechies

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


(Brent Royal-Gordon) #4

We’re thinking about it but there are no plans for Swift 3 in this respect

I didn't mean to imply otherwise. What I was trying to say is that it's on your team's radar and trying to propose it probably won't be especially helpful.

···

--
Brent Royal-Gordon
Sent from my iPhone