[swift-evolution] Take 2: Stdlib closure argument labels and parameter names

Erica Sadun erica at ericasadun.com
Wed Jun 29 10:13:58 CDT 2016

> On Jun 29, 2016, at 12:39 AM, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
> I've updated my pull request with a much more conservative set of
> changes that preserves/restores label-free-ness for all “term of art”
> functional methods such as filter and reduce.
> https://github.com/apple/swift/pull/2981
> My current thoughts are that many of the `by:` labels are awkward and
> not adding much.  Perhaps they all ought to be omitted.

I'd be happy to see `by` labels go away, whether first or trailing. I'm not sure why Swift 3 wants 
to have so many extra labels when a very simple phrase is understandable on its own 
(e.g. max, min, sort, sorted).

Is it possible under the Swift umbrella to do the same for split since it has the rarely used
maxSplits, and omittingEmptySubsequences params? It would give you `split({$0 == " "})` 
and `split(atWhitespace)`.

Speaking of isAllWhitespace, would this be a prebuilt enumeration or is it a placeholder?
If the former, I have opinions (new lines, new lines and whitespace)

The managed buffer, are you "makingValueWith" instead of "makingHeaderWith" intentionally?
If so, no worries. If not, helpful ping.

Future Extensions:

* reduce(_:, combine:)  // way simpler

* "The argument against changing other names to be more consistent with API guidelines 
is weakened. "

 I think Sean Heber's `@termOfArt(name)` is a great way to have both worlds, where 
`select(where:)` or `where()` is the Swifty name and `@termOfArt(filter)` offers
a substitutable alias for fp aficionados. 

This approach is not anything I've ever seen previously in a programming language but 
its something that jumps out as a way to satisfy two distinct audiences of users
that would have limited impact but a decided advantage.

That said, I don't like `mapping` and `flattened`. If they're going to be Swiftized, go with
names that aren't standing in the "term of art" rubble: transform, squeeze, whatever.

-- E

More information about the swift-evolution mailing list