[swift-evolution] [Guidelines, First Argument Labels]: Prepositions inside the parens

Dave Abrahams dabrahams at apple.com
Sat Feb 13 12:42:54 CST 2016


on Sat Feb 13 2016, 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?

Yes, "for" would be better than "with."  Whether it's enough-better than
no label at all is unclear to me.

>> -  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, delegates are weird.

-- 
-Dave


More information about the swift-evolution mailing list