# \[Guidelines, First Argument Labels\]: Prepositions inside the parens

**URL:** <https://forums.swift.org/t/guidelines-first-argument-labels-prepositions-inside-the-parens/1369>\
**Category:** Discussion\
**Created:** [February 9, 2016, 7:18pm UTC](https://forums.swift.org/t/guidelines-first-argument-labels-prepositions-inside-the-parens/1369 "2016-02-09T19:18:00Z")\
**Posts on this page:** 8\
**Page:** 4

<div class="post-metadata">

**Author:** ![dabrahams](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/dabrahams/32/9815_2.png) [@dabrahams](https://forums.swift.org/u/dabrahams)\
**Post date:** [February 13, 2016, 6:42pm UTC](https://forums.swift.org/t/guidelines-first-argument-labels-prepositions-inside-the-parens/1369/61 "2016-02-13T18:42:54Z")

</div>

> > - 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  
> > &nbsp;&nbsp;&nbsp;@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.

> **···**
>
> 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@swift.org\> wrote:
> 
> --  
> -Dave

---

<div class="post-metadata">

**Author:** ![Brent\_Royal-Gordon](https://avatars.discourse-cdn.com/v4/letter/b/53a042/32.png) [@Brent\_Royal-Gordon](https://forums.swift.org/u/Brent_Royal-Gordon)\
**Post date:** [February 13, 2016, 8:57pm UTC](https://forums.swift.org/t/guidelines-first-argument-labels-prepositions-inside-the-parens/1369/62 "2016-02-13T20:57:51Z")

</div>

> Yeah, delegates are weird.

Did you ever see this suggestion of mine in the delegate method thread? \<[http://article.gmane.org/gmane.comp.lang.swift.evolution/5777&gt](http://article.gmane.org/gmane.comp.lang.swift.evolution/5777&gt); It seems like you'd already concluded that there was no good solution and moved on to other topics, so I'm not sure if you did.

(If you \*did\* see it and dismissed it, sorry to bother you!)

> **···**
>
> --  
> Brent Royal-Gordon  
> Architechies

---

<div class="post-metadata">

**Author:** ![dabrahams](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/dabrahams/32/9815_2.png) [@dabrahams](https://forums.swift.org/u/dabrahams)\
**Post date:** [February 13, 2016, 9:24pm UTC](https://forums.swift.org/t/guidelines-first-argument-labels-prepositions-inside-the-parens/1369/63 "2016-02-13T21:24:34Z")

</div>

I saw it. I don't think it's a foregone conclusion that there's no good  
solution to delegate methods, but I do think the problem is a big hairy  
one that deserves its own proposal. Having a whole separate set of  
guidelines to cover delegates would be unfortunate so I hope the  
eventual solution is something we can do entirely in the importer and  
brings these APIs into line with the rest of the frameworks.

> **···**
>
> on Sat Feb 13 2016, Brent Royal-Gordon \<brent-AT-architechies.com\> wrote:
> 
> > > Yeah, delegates are weird.
> > 
> > Did you ever see this suggestion of mine in the delegate method  
> > thread?  
> > \<[http://article.gmane.org/gmane.comp.lang.swift.evolution/5777&gt](http://article.gmane.org/gmane.comp.lang.swift.evolution/5777&gt); It  
> > seems like you'd already concluded that there was no good solution and  
> > moved on to other topics, so I'm not sure if you did.
> 
> --  
> -Dave

---

<div class="post-metadata">

**Author:** ![Brent\_Royal-Gordon](https://avatars.discourse-cdn.com/v4/letter/b/53a042/32.png) [@Brent\_Royal-Gordon](https://forums.swift.org/u/Brent_Royal-Gordon)\
**Post date:** [February 13, 2016, 10:42pm UTC](https://forums.swift.org/t/guidelines-first-argument-labels-prepositions-inside-the-parens/1369/64 "2016-02-13T22:42:42Z")

</div>

> I saw it. I don't think it's a foregone conclusion that there's no good  
> solution to delegate methods, but I do think the problem is a big hairy  
> one that deserves its own proposal. Having a whole separate set of  
> guidelines to cover delegates would be unfortunate so I hope the  
> eventual solution is something we can do entirely in the importer and  
> brings these APIs into line with the rest of the frameworks.

Okay, if the plan is to punt on delegates and think about them later, I think we can just decide not to fuss over them right now.

> **···**
>
> --  
> Brent Royal-Gordon  
> Architechies

---

<div class="post-metadata">

**Author:** ![Radek\_Pietruszewski](https://avatars.discourse-cdn.com/v4/letter/r/74df32/32.png) [@Radek\_Pietruszewski](https://forums.swift.org/u/Radek_Pietruszewski)\
**Post date:** [February 13, 2016, 4:47pm UTC](https://forums.swift.org/t/guidelines-first-argument-labels-prepositions-inside-the-parens/1369/65 "2016-02-13T16:47:17Z")

</div>

> > - 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  
> > &nbsp;&nbsp;@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.

> **···**
>
> > On 13 Feb 2016, at 17:44, Haravikk \<swift-evolution@haravikk.me\> wrote:
> > 
> > > On 13 Feb 2016, at 10:51, Radosław Pietruszewski via swift-evolution \<swift-evolution@swift.org\> wrote:

---

<div class="post-metadata">

**Author:** ![dabrahams](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/dabrahams/32/9815_2.png) [@dabrahams](https://forums.swift.org/u/dabrahams)\
**Post date:** [February 12, 2016, 1:41am UTC](https://forums.swift.org/t/guidelines-first-argument-labels-prepositions-inside-the-parens/1369/66 "2016-02-12T01:41:36Z")

</div>

> > Doug and I reviewed these, and we don't think they work. The right  
> > criterion for cocoa seems to be “pull ‘of’ into the base name unless—as  
> > Jordan suggested—it means “having.”
> > 
> > Fortunately that seems to be easily determined. After looking at all  
> > the APIs in Cocoa, “of” in the base name means “having” exactly when it  
> > is followed by one of the following words: “type,” “types,” “kind,”  
> > “size,” “length,” and maybe “stage” (we're trying to analyze  
> > removeModifiersOfStage  
> > \<[SCNParticleSystem | Apple Developer Documentation](https://developer.apple.com/library/mac/documentation/SceneKit/Reference/SCNParticleSystem_Class/#//apple_ref/doc/uid/TP40014177-CH1-SW132)  
> > \<[SCNParticleSystem | Apple Developer Documentation](https://developer.apple.com/library/mac/documentation/SceneKit/Reference/SCNParticleSystem_Class/#//apple_ref/doc/uid/TP40014177-CH1-SW132&gt;&gt);  
> > to figure out how “of”is being used—assistance welcome).
> 
> As usual, I object to hardcoded supposedly-exhaustive lists. I'd  
> rather have people fix these up manually with NS\_SWIFT\_NAME and such.

We could “automatically fix them up manually” with NS\_SWIFT\_NAME and let  
the framework owners review the patches, but since we know exactly which  
ones work it would be a huge waste to ask each framework owner to find  
them on their own.

> Given that the parallel to -removeModifiersOfStage: is  
> -addModifierForProperties:atStage:withBlock:, I think the stage is not  
> being treated as part of the modifier.

I don't think I understand what you wrote above, sorry.

> **···**
>
> on Thu Feb 11 2016, Jordan Rose \<swift-evolution@swift.org\> wrote:
> 
> > > On Feb 11, 2016, at 16:00, Dave Abrahams via swift-evolution \>\> \<swift-evolution@swift.org\> wrote:
> 
> --  
> -Dave

---

<div class="post-metadata">

**Author:** ![jrose](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jrose/32/408_2.png) [@jrose](https://forums.swift.org/u/jrose)\
**Post date:** [February 12, 2016, 2:32am UTC](https://forums.swift.org/t/guidelines-first-argument-labels-prepositions-inside-the-parens/1369/67 "2016-02-12T02:32:41Z")

</div>

> > > Doug and I reviewed these, and we don't think they work. The right  
> > > criterion for cocoa seems to be “pull ‘of’ into the base name unless—as  
> > > Jordan suggested—it means “having.”
> > > 
> > > Fortunately that seems to be easily determined. After looking at all  
> > > the APIs in Cocoa, “of” in the base name means “having” exactly when it  
> > > is followed by one of the following words: “type,” “types,” “kind,”  
> > > “size,” “length,” and maybe “stage” (we're trying to analyze  
> > > removeModifiersOfStage  
> > > \<[SCNParticleSystem | Apple Developer Documentation](https://developer.apple.com/library/mac/documentation/SceneKit/Reference/SCNParticleSystem_Class/#//apple_ref/doc/uid/TP40014177-CH1-SW132)  
> > > \<[SCNParticleSystem | Apple Developer Documentation](https://developer.apple.com/library/mac/documentation/SceneKit/Reference/SCNParticleSystem_Class/#//apple_ref/doc/uid/TP40014177-CH1-SW132&gt;&gt);  
> > > to figure out how “of”is being used—assistance welcome).
> > 
> > As usual, I object to hardcoded supposedly-exhaustive lists. I'd  
> > rather have people fix these up manually with NS\_SWIFT\_NAME and such.
> 
> We could “automatically fix them up manually” with NS\_SWIFT\_NAME and let  
> the framework owners review the patches, but since we know exactly which  
> ones work it would be a huge waste to ask each framework owner to find  
> them on their own.

Yes, I'm fine with that. My point is I don't want it added to the automatic translation rules. (I expect to be overruled, again.)

> > Given that the parallel to -removeModifiersOfStage: is  
> > -addModifierForProperties:atStage:withBlock:, I think the stage is not  
> > being treated as part of the modifier.
> 
> I don't think I understand what you wrote above, sorry.

This is in reference to "we're trying to analyze -removeModifiersOfStage: to figure out how 'of' is being used—assistance welcome". My reading is that it is not an "of" that really means "having".

Jordan

> **···**
>
> > On Feb 11, 2016, at 17:41, Dave Abrahams via swift-evolution \<swift-evolution@swift.org\> wrote:  
> > on Thu Feb 11 2016, Jordan Rose \<swift-evolution@swift.org\> wrote:
> > 
> > > > On Feb 11, 2016, at 16:00, Dave Abrahams via swift-evolution \>\>\> \<swift-evolution@swift.org\> wrote:

---

<div class="post-metadata">

**Author:** ![dabrahams](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/dabrahams/32/9815_2.png) [@dabrahams](https://forums.swift.org/u/dabrahams)\
**Post date:** [February 12, 2016, 6:28am UTC](https://forums.swift.org/t/guidelines-first-argument-labels-prepositions-inside-the-parens/1369/68 "2016-02-12T06:28:40Z")

</div>

That's nice, then. It means 3 fewer NS\_SWIFT\_NAMEs or one fewer  
automatic import rules (if you're overruled).

> **···**
>
> on Thu Feb 11 2016, Jordan Rose \<swift-evolution@swift.org\> wrote:
> 
> > > On Feb 11, 2016, at 17:41, Dave Abrahams via swift-evolution \<swift-evolution@swift.org\> wrote:
> > > 
> > > on Thu Feb 11 2016, Jordan Rose \<swift-evolution@swift.org\> wrote:
> > > 
> > > > > On Feb 11, 2016, at 16:00, Dave Abrahams via swift-evolution \>\>\>\> \<swift-evolution@swift.org\> wrote:
> > > > > 
> > > > > Doug and I reviewed these, and we don't think they work. The right  
> > > > > criterion for cocoa seems to be “pull ‘of’ into the base name unless—as  
> > > > > Jordan suggested—it means “having.”
> > > > > 
> > > > > Fortunately that seems to be easily determined. After looking at all  
> > > > > the APIs in Cocoa, “of” in the base name means “having” exactly when it  
> > > > > is followed by one of the following words: “type,” “types,” “kind,”  
> > > > > “size,” “length,” and maybe “stage” (we're trying to analyze  
> > > > > removeModifiersOfStage  
> > > > > \<[SCNParticleSystem | Apple Developer Documentation](https://developer.apple.com/library/mac/documentation/SceneKit/Reference/SCNParticleSystem_Class/#//apple_ref/doc/uid/TP40014177-CH1-SW132)  
> > > > > \<[SCNParticleSystem | Apple Developer Documentation](https://developer.apple.com/library/mac/documentation/SceneKit/Reference/SCNParticleSystem_Class/#//apple_ref/doc/uid/TP40014177-CH1-SW132&gt;&gt);  
> > > > > to figure out how “of”is being used—assistance welcome).
> > > > 
> > > > As usual, I object to hardcoded supposedly-exhaustive lists. I'd  
> > > > rather have people fix these up manually with NS\_SWIFT\_NAME and such.
> > > 
> > > We could “automatically fix them up manually” with NS\_SWIFT\_NAME and let  
> > > the framework owners review the patches, but since we know exactly which  
> > > ones work it would be a huge waste to ask each framework owner to find  
> > > them on their own.
> > 
> > Yes, I'm fine with that. My point is I don't want it added to the  
> > automatic translation rules. (I expect to be overruled, again.)
> > 
> > > > Given that the parallel to -removeModifiersOfStage: is  
> > > > -addModifierForProperties:atStage:withBlock:, I think the stage is not  
> > > > being treated as part of the modifier.
> > > 
> > > I don't think I understand what you wrote above, sorry.
> > 
> > This is in reference to "we're trying to analyze  
> > -removeModifiersOfStage: to figure out how 'of' is being  
> > used—assistance welcome". My reading is that it is not an "of" that  
> > really means "having".
> 
> --  
> -Dave

[Previous page](https://forums.swift.org/t/guidelines-first-argument-labels-prepositions-inside-the-parens/1369.md?page=3)
