[swift-evolution] [Guidelines, First Argument Labels]: Prepositions inside the parens
Radosław Pietruszewski
radexpl at gmail.com
Sat Feb 13 10:47:17 CST 2016
> On 13 Feb 2016, at 17:44, Haravikk <swift-evolution at haravikk.me> wrote:
>
>
>> On 13 Feb 2016, at 10:51, Radosław Pietruszewski via swift-evolution <swift-evolution at swift.org> wrote:
>>
>> - func magnifyToFit(rect: Rect)
>> + func magnify(toFit rect: Rect)
>>
>> Intentional? I guess it could be argued either way, but “magnify-to-fit” seems like one phrase.
>
> I prefer the change; to me “magnify” is the operation, the rectangle just happens to be what controls the result. It makes sense IMO that there could be other magnify operations with different requirements.
>
>> (NSArray)
>> + func description(withLocale locale: AnyObject?) -> String
>> + func description(withLocale locale: AnyObject?, indent level: Int) -> String
>>
>> Another case where `with` doesn’t add anything IMHO and in fact makes things slightly confusing. The description isn’t somehow made *with* the locale, it’s just a variant of the `description` property that takes a locale as an setting.
>
> I suppose in this case withLocale might be clearer as forLocale or withinLocale or something along those lines?
I’d be cool with just ‘locale’, but `forLocale` definitely works far better than `withLocale`.
>
>> - optional func scrollViewShouldScrollTo(top scrollView: UIScrollView) -> Bool
>> + optional func scrollViewShouldScroll(toTop scrollView: UIScrollView) -> Bool
>> @available(iOS 2.0, *)
>> - optional func scrollViewDidScrollTo(top scrollView: UIScrollView)
>> + optional func scrollViewDidScroll(toTop scrollView: UIScrollView)
>>
>> Similar case as “magnify to fit”. the scroll view has nothing to do with “toTop”. It should be:
>
> I think in this case it’s less clear than magnify, as it’s a bit of a weird pattern to begin with. It depends really on whether you feel that scrollViewShouldScroll is a discrete event that could potentially have different parameters (e.g- toBottom etc.) in which case it’s a good distinction to have. Not nearly as clear to me as magnify though, it’s not a style of callback that I like at all =)
Yeah I'm not a huge fan of the standard ObjC delegate style either, but I’m not debating that. But `toTop` as a argument label for the UIScrollView makes no sense.
More information about the swift-evolution
mailing list