To better explain my previous post:
I know that there are pragmatic performance considerations. For the better or for the worse, the choice between mutable and immutable variants is currently important. A bad choice can turn an innocuous-looking piece of code into a quadratic beast, or worse.
Yet, the reduce
/ reduce(into:)
story had taught us something. It is that the stdlib first had the general and optimistic reduce
. And that only after, a well-motivated proposal brought us reduce(into:)
because Swift and the stdlib are ruled by pragmatic people.
The pitched mutating func mapInPlace(_ x: (inout Element) -> ())
looks to me like it jumps over a more general and optimistic mutating func mapInPlace(_ x: (Element) -> Element)
.
I think that we'd miss the general variant if it weren't introduced. And that the inout-optimized variant could be well-motivated by pragmatic performance/memory considerations. This would turn this pitch into a proposal that introduces two "map in place" methods.