[swift-evolution] rename dropFirst() and dropLast()

Kevin Ballard kevin at sb.org
Tue Dec 29 18:29:12 CST 2015


On Tue, Dec 29, 2015, at 03:39 PM, Daniel Duan wrote:
> 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.

I don't read it either way. As suggested in my previous email, I'd read this as "transforms someText by *splitting newlines* (and returns the result)". It's not entirely clear how to classify this usage (since grammar is confusing), but it's kind of a moot point because Wikipedia says:

> The distinction between gerund and present participles is not recognised in modern reference grammars, since many uses are ambiguous.

And it doesn't really matter anyway because the guidelines don't say that the non-mutating variant has to read as a noun phrase, it just says to name it using the appropriate -ed/-ing ending. And in the case of strippingNewlines(), this makes sense, as it's the non-mutating counterpart to stripNewlines().

But in the case of dropFirst(), this is not a non-mutating counterpart to removeFirst(). dropFirst() is defined on SequenceType, which has no removeFirst(). If anything, removeFirst() is a mutating version that's derived from dropFirst() (although not really, since removeFirst() is named after removeAtIndex() and the only naming relation it has to dropFirst() is re-using the same "First" suffix).

-Kevin


More information about the swift-evolution mailing list