How does the standard library get audited to be as good as Algorithms, Collections, etc.?

FWIW, the full Swift Evolution process is documented here: swift-evolution/process.md at main · apple/swift-evolution · GitHub.

1 Like

@anon9791410 Funnily enough, the standard library actually has an implementation of that already. Sort of.

This post, especially the title, is phrased as if it is a given that the version of reduce you propose is so "obviously" necessary that it is essentially a bug that it doesn't already exist.

But in practice, reductions and reduce are not the same. reductions returns an array, so an overload that returns an empty array is a natural step with little downside. Whereas reduce would have a different return type – an optional Element? instead of a non-optional T. Maybe that's fine, maybe it's added complexity that weighs against it, but it's a significant difference.

This variant of reduce has already been pitched in the past and the response was mixed. Several posts questioned the general utility for this addition. So it's not really appropriate to frame this as if its absence means something is wrong.

I suggest editing the title to not presuppose so much. But to answer a possible rephrasing of the question: "How can the standard library adopt some good idioms from the algorithms package?" the answer is to pitch them, see if they have broad support, and if so we can run a review.

13 Likes