FWIW, in .Net the equivalent of Sequence is IEnumerable, and the equivalent of 
IteratorProtocol is IEnumerator. In .Net there are extension methods for 
IEnumerable for things like First, Last, and SequenceEqual. Like Swift’s 
Sequence, .Net’s IEnumerable makes no promises about the order of iteration 
being semantically meaningful (that’s up to the implementation) or 
non-destructive. That does mean you should be aware of what kind of thing 
you’re iterating over before using some of the extension methods, but they are 
still useful. And, as in Swift, .Net’s Set type implements IEnumerable. I don’t 
think this is a flaw in .Net, and I don’t think it’s a flaw in Swift.

It seems some people are getting hung up on the natural language definition of 
Sequence and whether that name accurately describes what Swift’s type 
represents. I don’t think the name is inaccurate. It’s still a Sequence, even 
if it’s an arbitrary one.

Some people are also getting hung up on whether it makes sense to have these 
operations on collections that don’t define an order. Maybe not always, and 
maybe not usually, but I can tell you I’ve at least used First on a Set in 
.Net, and I’d rather that Set implement IEnumerable and get all the useful 
things that come with it (even if that means also getting a few that don’t make 
sense) than have to deal with distinct types that are only occasionally 
different.

I think plenty of .Net developers have been productive for years without this 
being a problem. I think Swift developers can handle it too.

I’m not even sure a name change is necessary for this method at all, but I’m 
not at all in favor of anything beyond that.
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to