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

Vladimir.S svabox at gmail.com
Tue Jun 21 10:10:01 CDT 2016


On 21.06.2016 0:56, Brent Royal-Gordon via swift-evolution wrote:
>>> 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

Why not x.select(where: isPrime) ? IMO this is more clear than
x.select(filter: isPrime) and looks similar to `where` in other parts of 
language.

> 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

FWIW  `Where` is used as method also in c#

Example:
IEnumerable<int> numQuery2 = numbers.Where(num => num % 2 == 0).OrderBy(n 
=> n);

> 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.
>


More information about the swift-evolution mailing list