SE-0231 — Optional iteration

  • What is your evaluation of the proposal?

+1 to the alternative location of the ? after the optional value.

  • Is the problem being addressed significant enough to warrant a change to Swift?

I frequently find myself reflexively writing for let s = seq, x in s { ... }, but I never care about the binding of s beyond the rest of the for loop. I prefer the proposed semantics of nil meaning no iteration.

  • Does this proposal fit well with the feel and direction of Swift?

The alternative ? after the optional value feels consistent with optional chaining.

It might be inconsistent with optional patterns as the "Alternatives Considered" section mentions. Then again, I always have to look up the syntax for optional patterns every time I read or write them, so I'd prefer consistency with chaining over consistency with optional patterns.

  • If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?

Not with this degree of built-in syntactic support for optional and preference for procedural code.

  • How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

Brief reading of proposal and thread.

1 Like