Swift Proposal: Pack Iteration
Currently, it is possible to express list operations on value packs using pack expansion expressions. This approach requires putting code involving statements into a function or closure. For example, limiting repetition patterns to expressions does not allow for short-circuiting with
break
orcontinue
statements, so the pattern expression will always be evaluated once for every element in the pack. The only way to stop evaluation would be to mark the function/closure containing the pattern expression throwing, and catch the error in a do/catch block to return, which is unnatural for Swift users.[…]
We propose allowing iteration over value packs using
for-in
loops. With the adoption of pack iteration, the implementation of the standard library methods like==
operator for tuples of any number of elements will become straightforward.
It’s accepted.
Previously:
1 Comment RSS · Twitter · Mastodon
I read through these proposals, and every single seems to be:
"For ideological reasons, we made things unnecessarily complex and so things you would reasonably expect to work don't work. Therefore, we've decided to add another 50 pages of complexity..."
(This is recursive, so when you click through to the previous thing they are trying to fix here, it follows the same pattern)