[swift-evolution] [Draft] Apply -ed/-ing rule to core functional methods (e.g. filter => filtered)

Brent Royal-Gordon brent at architechies.com
Mon Jun 20 16:56:14 CDT 2016


>> And as I said, if we feel `filter` is unsalvageable, the alternate
>> Smalltalk-lineage `select` is clearer.
> 
> Than “where?”

No, than "filter". "filter" is the most common name, but "select" is also fairly popular, and doesn't have the same ambiguity issues as "filter". "where" is slightly clearer than "filter", but it finds little precedent in other languages (the only other use I'm aware of is in SQL and LINQ, which are declarative), ignores the normal grammar rules for a method ("where" is an adverb, not a noun or verb), and is already a language keyword which has been overloaded with several slightly different semantics, including list filtering in the `for` loop.

>>> – There's very significant brevity issues here, e.g. hyperbolicArcTangent() vs atanh().
>> 
>> Sure, but `mappingAndFlattening(to:)` would have brevity issues as
>> well. (You didn't think the API Guidelines merely meant "add -ed or
>> -ing to everything", did you?)
> 
> That would, IMO, be:
> 
>  x.flatMapping(fourCopies)

Why? If we're leaving the terms of art behind, we probably ought to consider that the base name `flatMap` is rather opaque to new users; I've seen people in my NSCoder group struggle with it. For that matter, `map` and `reduce` aren't the best names either.

I can understand wanting to keep terms of art even if they're a little opaque. I can understand wanting to invent new, clear terms. I cannot understand wanting to make minor cosmetic changes to the terms of art while still keeping the parts that make them opaque. You lose many of the benefits of a term of art *and* most of the benefits of a new term.

It's a bit like painting a single wall in a room: You can match the existing color exactly and have it look seamless, or you can choose an obviously different color and make a statement, but choosing a slightly different shade of the existing color does neither of those things.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list