SE-0231 — Optional iteration

  • What is your evaluation of the proposal?

+0.5 given the alternative for element in sequence?

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

I'm not sure; it's not one that I've encountered often, and I'm sympathetic to the argument about optional sequences as a design smell. But I want to give other people the benefit of the doubt about how much they would use it. And see next question.

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

Yes, given the ? being applied to the value, not the keyword, I think it fits snugly with other Optional handling. Putting the question mark on the value looks like a pattern match to me, like the case .a? syntax that was mentioned.* I think it's an easy thing to understand and makes the statement more succinct without loss of clarity, like other Optional sugar.

I think this is a nice affordance for those who want it, without causing undue harm to those who would prefer not to use it.

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

n/a

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

I read the proposal and the review thread through.


*Although saying this makes me think that the ideal solution might be if this really were sugar for a pattern match. for element in seq where case let .some(seq) = sequence perhaps? But I don't want to get off-track.

1 Like