# Renaming Trailing-closure Functions in the Standard Library

**URL:** <https://forums.swift.org/t/renaming-trailing-closure-functions-in-the-standard-library/35454>\
**Category:** Pitches\
**Created:** [April 17, 2020, 3:13pm UTC](https://forums.swift.org/t/renaming-trailing-closure-functions-in-the-standard-library/35454 "2020-04-17T15:13:39Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![cukr](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/cukr/32/889_2.png) [@cukr](https://forums.swift.org/u/cukr)\
**Post date:** [April 17, 2020, 4:22pm UTC](https://forums.swift.org/t/renaming-trailing-closure-functions-in-the-standard-library/35454/10 "2020-04-17T16:22:51Z")

</div>

```swift
// this reads well 
array.first(where: { criteria })
// but this is not at all clear 
array.first { criteria }

```

I agree, second one isn't good. Thankfully we can write it the first way!  
There is a solution in place already, so why do we have to change the stdlib?

> [@ben-cohen](#):
>
> applying the beneficial argument label to the base name instead would make these considerably more readable regardless of whether the trailing closure is applied:

I don't see how `firstWhere(...)` is more readable than `first(where: ...)`.

> [@ben-cohen](#):
>
> your [meaningful] trailing closure label (...) will be left off 90% of the time

I don't understand why this. Some labels are useful enough to include it in your code. Some labels are not. That's why I include some of the labels in my code, and don't include some of them. For example I when I call `first(where:)` function, I always write the label down.

Current situation:

```swift
  +----------------------------------+ 
  |Is the label meaningful enough | 
  |to include it in your source code?| 
  +----------------------------------+ 
    | |   
    | |   
   Yes |   
    | No   
    v |   
 Include it in your source code |   
                                   v  
                                Skip it

```

What you are suggesting:

```swift
  +----------------------------------+ 
  |Is the label meaningful enough | 
  |to include it in your source code?| 
  +----------------------------------+ 
           | |               
           | |               
          Yes No               
           | |               
           V V               
    Include it in your source code  

```

Would that be better for people that think that these labels are useful? I don't think so, they should be writing them already. Would that be better for people that think that these labels should be skipped? I don't think so, you would be forcing them to go against what they want.

> [@ben-cohen](#):
>
> Additionally, we have the case of [SE-0220](https://github.com/apple/swift-evolution/blob/master/proposals/0220-count-where.md) which introduced `Sequence.count(where: (Element)->Bool)` , which had to be backed out because the basename was ambiguous with `Collection.count` , leading to performance problems in the type checker:

I feel like [Require parameter names when referencing to functions](https://forums.swift.org/t/require-parameter-names-when-referencing-to-functions/27048) is a better solution for that. Renaming specific functions one by one doesn't solve the root of the problem.

---

_[View the full topic](https://forums.swift.org/t/renaming-trailing-closure-functions-in-the-standard-library/35454)._
