[swift-evolution] [SR-933] Rename flatten to flattened

Haravikk swift-evolution at haravikk.me
Fri Apr 8 08:38:55 CDT 2016


> On 8 Apr 2016, at 12:00, Pyry Jahkola <pyry.jahkola at iki.fi> wrote:
> 
> 
>> On 08 Apr 2016, at 13:19, Haravikk via swift-evolution <swift-evolution at swift.org <mailto: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.

I’m not sure if sine, cosine etc. are equivalent to the case of map, flatten and so-on? Are they not nouns rather than verbs?
I don’t think googleable should be that important; what’s important is what the method does, i.e- what you want to do, as long as it’s well described it should still be searchable, especially if there is a mutating equivalent that’s named in present tense.

> 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)} // ???
> 
> 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.

True enough, didn’t think that through, though mapping where the type remains unchanged would be possible. Not really the point though, I think it should still be named consistently; if you make exceptions then why have guidelines on naming at all?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160408/13d31404/attachment.html>


More information about the swift-evolution mailing list