[swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)
david at alkaline-solutions.com
Thu Nov 16 12:07:45 CST 2017
> On Nov 15, 2017, at 7:16 PM, Greg Parker via swift-evolution <swift-evolution at swift.org> wrote:
>> On Nov 15, 2017, at 5:53 PM, John McCall <rjmccall at apple.com <mailto:rjmccall at apple.com>> wrote:
>>> On Nov 15, 2017, at 7:36 PM, Greg Parker via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> "compactMap" is okay if "compact" is added. Is "compact" a common enough operation in practice to pull its own weight?
It might be a good criteria, given placeholder ‘xxx’ which is a verb, to think of whether for xxxMap or xxxedMap, if xxx/xxxed would be acceptable and descriptive terms. We didn’t have flattened() for flatMap, so I think whether xxxed() is present or not is a separate question.
Optional is an adjective, so there may be an ‘xxx’ in the function xxxMap which is also an adjective. Not sure how that plays into the naming conventions.
>>> "mapSome" is great if you know about Optional.Some but terrible if you don't. ("Okay, it maps some elements, but which ones?")
>>> "mapNonNil" is obvious and ugly and perhaps its obviousness makes it a winner.
>> mapSome and especially mapNonNil both sound to me like they only map the non-nil values in the source sequence.
> I thought it did map the non-nil values in the source sequence. Did I misunderstand what the proposed filterMap does? It occurs to me that the proposal does not have a standalone description of the filterMap operation.
It maps all values to optional results, discarding any results which are nil and returning just a collection of the unwrapped results - right?
Speaking of which, I don’t feel Sequence.unwrapped() passes muster per my stated criteria above.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution