[swift-evolution] [swift-evolution-announce] [Accepted with revisions] SE-0187 “Introduce Sequence.filterMap(_:)”

Paul Cantrell cantrell at pobox.com
Tue Dec 19 21:46:10 CST 2017


Yes. If we’re fussing over the verb tense, “compacted” is clearly correct. Where did “compacting” come from? The API guidelines state:

> Prefer to name the nonmutating variant using the verb’s past participle (usually appending “ed”).


…and (emphasis added):

> When adding “ed” _is not grammatical because the verb has a direct object_, name the nonmutating variant using the verb’s present participle, by appending “ing.” 

Thus “joined” and “sorted” — also no-args methods where the verb has no direct object.

BUT

The existing methods “filter” and “reduce” seem the nearest peers to the proposed “compact,” and we do not call them “filtered” and “reduced.” Those are the methods with which the new one should maintain consistency.

P


> On Dec 19, 2017, at 5:52 PM, Nevin Brackett-Rozinsky via swift-evolution <swift-evolution at swift.org> wrote:
> 
> If we’re bikeshedding the verb tense then “compactMap” sounds right to me, and adding “ing” would be needlessly verbose.
> 
> For the non-mapping version, I’d lean toward “compacted”. However, we could also postpone the debate over its spelling until such time as we are actually ready to introduce it.
> 
> Nevin
> 
> 
> 
> On Tue, Dec 19, 2017 at 6:42 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> 
> 
>> On Dec 19, 2017, at 2:28 PM, Xiaodi Wu via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> I disagree. Let’s not reopen what is settled. “Compact” can be a noun just as “map” and “filter” can; as long as there are no in-place variants, there can be no ambiguity.
>> On Tue, Dec 19, 2017 at 17:11 Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> On Dec 19, 2017, at 8:56 AM, John McCall <rjmccall at apple.com <mailto:rjmccall at apple.com>> wrote:
>>> 
>>> Therefore, SE-0187 is accepted, with the revision that the new name be Sequence.compactMap(_:), and with the agreement that we will add Sequence.compact() when it is possible to do so.
>> 
>> 
>> I like `compact` as the basis for the name, but I hope the core team will consider whether the eventual nil-removal method should be called `compacting()`, and whether therefore this method should be called `compactingMap(_:)`. Prior art on the name `compact()` does exist, but I don't think it's strong enough to justify deviating from the API Guidelines.
>> 
>> I don't think we need a full review on this tiny issue; five minutes of the core team's time should more than suffice.
> 
> I agree with Brent. IMO we're firmly outside the domain of established terms-of-art here (Ruby notwithstanding). 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

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


More information about the swift-evolution mailing list