I have an additional objection to the reasoning for enforcing no labels for first trailing closures.
the new syntax rules are:
- The first trailing closure drops its argument label (like today).
- Subsequent trailing closures require argument labels.
These rules seem to work well in practice, because functions with multiple closure arguments tend to have one that is more primary. Often any additional closure arguments are optional (via default parameter values or overloading), in order to provide progressive disclosure
Even thought there is some truth to that some "functions with multiple closure arguments tend to have one that is more primary", it doesn't justify the rule. The primary parameter doesn't necessarily happen to be the first parameter in a function declaration. And, regardless of that, the primary parameter's value doesn't necessarily happen to be the first trailing closure. This is clearly shown in the proposal's own examples:
ipAddressPublisher .sink(receiveCompletion: { completion in // handle error }) { identity in self.hostnames.insert(identity.hostname!) }
UIView.animate(withDuration: 0.3, animations: { self.view.alpha = 0 }) { _ in self.view.removeFromSuperview() }
The proposal uses the examples above to show that since the first parameters are the primary ones in the functions, the first trailing closures should have their labels omitted. However, the examples above (which will still be allowed if the proposal is accepted) clearly show that not all first trailing closures are the primary parameter values.