SE-0459: Add Collection conformances for enumerated()

Hi Swift community,

The review of SE-0459: Add Collection conformances for enumerated() begins now and runs through 7th of February, 2025.

This is a subsetted proposal previously part of SE-0312, which was returned for revision following issues with the zip aspect of the proposal. This proposal only includes the conformance for enumerated().

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. When emailing the review manager directly, please keep the proposal link at the top of the message.

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/main/process.md

Thank you,

Ben Cohen
Review Manager

14 Likes

Adding a comment as reviewer, not in my capacity as review manager:

Having read the alternative considered, I believe it would be better to only conform to BidirectionalCollection when the underlying collection is a RandomAccessCollection, in order to preserve constant-time access to the last index.

I appreciate that the O(n) cost is only on accessing the last index, not subsequently moving that index backwards, so that cost can be amortized over e.g. a full reversal. But while overall complexity of algorithms generally trumps constant time factors, I do think those constant time factors still matter and so shouldn't be waved away lightly. And it is entirely possible that functions generic over BidirectionalCollection might access the last element multiple times, considering it free, and so might incur the linear traversal cost more than once.

15 Likes

Much as I hate to curtail this heated discussion, the proposal has been accepted with modifications.

13 Likes