[swift-evolution] Stdlib closure argument labels and parameter names

Patrick Smith pgwsmith at gmail.com
Fri Jun 24 21:20:18 CDT 2016


Yes, I think the long names somewhat reduces the argument for keeping ‘terms of art’, as in this proposal the method names are describing themselves twice. Is the extra clarity for those who are not familiar with `filter`, `map`, `reduce` etc from other languages? Is this extra clarity actually helping — is someone going to say ‘ah it’s applying the transformation, now it makes sense’. From experience, these methods make sense after using them for the first time, not reading them in the documentation where even the longer description can feel quite abstract.

e.g. ‘accumulatingResultBy’ does not tell me much more than ‘reduce’, it’s probably not until they see an example or play around with it that someone new sees the utility of what it does and how it works.

Patrick

> On 24 Jun 2016, at 7:55 AM, Anton Zhilin via swift-evolution <swift-evolution at swift.org> wrote:
> 
> array.filter(isEven).map(square).reduce(sum)
> 
> reads better than
> 
> array.filter(suchThatTrue: isEven).map(applyingTransformation: 
> square).reduce(accumulatingResultBy: sum)
> 
> What do you think?



More information about the swift-evolution mailing list