[swift-evolution] rename dropFirst() and dropLast()
daniel at duan.org
Tue Dec 29 17:39:52 CST 2015
I suppose it’s appropriate to go into grammars since we are in a language mailing list :)
Present Participle is just an official name for “verb in present tense”, as in “I am *writing* an email”. Let’s put the example from API Guideline to test. I hope you agree that “someText.strippingNewlines()” as a non-mutating method name is grammatical *somehow*. So, does it read as
self is *stripping newlines*, here’s X.
…or does this make more sense…
*stripping newlines* from self gives X.
I tend to think the latter. There’s a fancy name for it as well: gerund phrase.
> On Dec 29, 2015, at 2:55 PM, Kevin Ballard <kevin at sb.org> wrote:
> On Tue, Dec 29, 2015, at 01:33 PM, Daniel Duan wrote:
>> For concrete types that conform to CollectionType:
>> [2, 1, 3].removeFirst() // => 2
>> [2, 1, 3].removingFirst() // => [1, 3]
>> seems like what the “non-mutating counterpart” guideline is aiming for. As another example, the guideline includes “stripNewlines()” and “strippingNewlines()”.
>> For SequenceType conforming types that aren’t CollectionTypes, they would be stuck with “removingFirst()”, which, technically, is a noun phrase (again, not my personal favorite). I don’t this result is against anything in the guidelines.
> It's technically not a noun phrase at all. I believe you're thinking of gerunds, where a verb with an -ing ending is used as a noun. But "removing" in "removingFirst()" is not being used as a noun; the method does not represent the act of removing, but instead it returns a new value constructed "by removing first". I believe this is called the Present Participle.
> -Kevin Ballard
More information about the swift-evolution