[swift-evolution] [SR-933] Rename flatten to flattened
Dave Abrahams
dabrahams at apple.com
Fri Apr 8 13:28:30 CDT 2016
on Fri Apr 08 2016, Pyry Jahkola <swift-evolution at swift.org> wrote:
> On 08 Apr 2016, at 13:19, Haravikk via swift-evolution
> <swift-evolution at swift.org> wrote:
>
> I think it makes sense to just rename them; it’s not as though flattened or
> mapped is somehow far removed from the original meaning as the actual action
> is the same, it’s just changing tense.
>
> -1, and not only for the reasons we neither call trigonometric functions `sine`,
> `cosine`, and `tangent`. The existing names are widely known, commonly taught in
> modern introductory programming courses, to the point, and googleable.
>
> In addition:
>
> If we want mutating forms of this methods then I much prefer .map() and .
> mapped() to .map() and .mapInPlace() or whatever, as the latter contradicts
> the naming convention used everywhere else which only adds confusion.
>
> This idea of in-place versions is innocuous but absurd. In general, there's no
> way mapping `T -> U` over a `[T]` could possibly accommodate the result in the
> argument of type `[T]`:
>
> var xs: [Int] = ...
> xs.mapInPlace {String($0)} // ???
No, you'd just give it a more-restricted signature that only accepted
T->T closures.
> And the same goes for `flatMap`, and `Optional` and others. Likewise, `flatten()
> ` couldn't possibly happen in place because the result type has one level of
> nesting less than the argument.
C'rect.
--
Dave
More information about the swift-evolution
mailing list