SE-0312: Add indexed() and Collection conformances for enumerated() and zip(_:_:)

Hello, Swift community.

The review of SE-0312: Add indexed() and Collection conformances for enumerated() and zip(::) begins now and runs through May 7th, 2021.

Reviews are an important part of the Swift evolution process. All review feedback should be either on this forum thread or, if you would like to keep your feedback private, directly to the review manager. If you do email me directly, please put "SE-0312" somewhere in the subject line.

What goes into a review?

The goal of the review process is to improve the proposal under review through constructive criticism and, eventually, determine the direction of Swift. When writing your review, here are some questions you might want to answer in your review:

  • What is your evaluation of the proposal?
  • Is the problem being addressed significant enough to warrant a change to Swift?
  • Does this proposal fit well with the feel and direction of Swift?
  • If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
  • How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

More information about the Swift evolution process is available at:

https://github.com/apple/swift-evolution/blob/master/process.md

As always, thank you for contributing to Swift.

Ben Cohen
Review Manager

22 Likes

+1

1 Like

+1

+1 seems great, a good addition

+1

+1

Is there a reason that Zip2Sequence is not getting a conditional conformance to LazySequenceProtocol?

1 Like

+1, seems obvious

+1

As far as this goes I would really like to have this but I imagine that should go through its own separate pitch with where this one is at.

zip is a free function, so a .lazy in one of its arguments is not part of the same method chain that the zip itself belongs to.

If zipping two sequences were instead spelled as seq1.zipped(with: seq2) then Zip2Sequence would have conditional conformance to LazySequenceProtocol whenever the first inner sequence conforms to it, i.e. .zipped(with: seq2) would be a continuation of seq1's method chain.

2 Likes

+1

+1

One small suggestion: I think it'd be good to rename the Indexed type to IndexedCollection. There's no harm in it being longer because it will rarely show up at the use site. Also, the longer name is more consistent with other type names in the standard library (like EnumeratedSequence) and less likely to cause naming conflicts.

6 Likes

+1

+1, especially for indexed().

Review Update

While the review of this feature was light with universal enthusiasm, the proposal author has requested it be sent back to pitch, due to discovery of an issue with zip and RandomAccessCollection conformance, which you can read more about on the new pitch thread.

Thanks to everyone who participated.

1 Like