[swift-evolution] [SHORT Review] SE-0133: Rename `flatten()` to `joined()`

Pyry Jahkola pyry.jahkola at iki.fi
Mon Jul 25 06:52:06 CDT 2016

> On 25 Jul 2016, at 09:10, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
> The review of "SE-0133: Rename `flatten()` to `joined()`" begins now and runs through July 26.  Apologies for the short review cycle, but we’re right up against the end of source breaking changes for Swift 3.  The proposal is available here:
> 	https://github.com/apple/swift-evolution/blob/master/proposals/0133-rename-flatten-to-joined.md
> 	* What is your evaluation of the proposal?

+1, this makes sense. The functions are very closely related, and while we have "flatten" in `flatMap`, is isn't unprecedented to call the joining operation `join` instead of `flatten`.

Flatten also somewhat suffers from the expectation that it would flatten arbitrary depths of nestings down to just one. (That would be absurd in Swift's type system, but is precedented in e.g. Clojure <http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/flatten>.) The word "join" instead sounds like a more 1-dimensional operation, and thus decreases the minor surprise factor.

It's also nice that `.joined(separator:)` can be simplified down to `.joined()` when the default separator is wanted. And I'd say the empty collection is an obvious choice for default in here.

> 	* Is the problem being addressed significant enough to warrant a change to Swift?

Yes, it makes the function easier to find.

> 	* Does this proposal fit well with the feel and direction of Swift?


> 	* If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?

Yes. E.g. Haskell calls it `join` <https://hackage.haskell.org/package/base->.

> 	* How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

Quick reading.

— Pyry

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160725/7418b306/attachment.html>

More information about the swift-evolution mailing list