SE-0555: `inout` overload of `BorrowingIteratorProtocol.skip(by:)`

Hello, Swift community!

The review of SE-0555: inout overload of BorrowingIteratorProtocol.skip(by:) begins now and runs through October 23rd, 2026.

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 me as the review manager by DM. When contacting the review manager directly, please put "SE-0555" 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 in the Swift evolution repository.

With thanks in advance for your consideration,

Tony Allevato
Review Manager

2 Likes

I have a thought about this "reversed polarity" issue for the inout parameter. Perhaps it is overthinking it, but I think it could be made unambiguous in a way that hasn't been talked about.

What if this new overload continued to return a discardable result, which would be the number of elements skipped:

@discardableResult
@export(implementation)
public mutating func skip(by offset: inout Int) throws(Failure) -> Int { ... }
  • When read alongside the existing overload of skip(by:), the return value remains consistent (and hence would prompt the user to consider how the inout value would differ, as it'd be a weird API that gives you the same result in two ways).
  • When read alongside the UniqueArray.formIndex(_:offsetBy:limitedBy:) precedent, the inout value remains consistent.
  • And since the default implementation is made @export(implementation), if a user discards the return value, the compiler can presumably eliminate even the minor overhead of computing offset &- remainder. There's also no additional surface-level ceremony imposed by having this discardable result.

Wdyt?

1 Like

That's an interesting idea. We should figure out whether the optimizer does elide the calculation.

The Language Steering Group has accepted this proposal with modifications.

1 Like