rename dropFirst() and dropLast()

What about shift and pop?

They both could take an argument of a number of items to shift or pop ?

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.

withoutFirst()
withoutLast()

-Thorsten

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.

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.

Yes, we got a wad of technical corrections from an Apple linguist that have yet to be applied to the guidelines document. That was one of them.

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).

The fact that SequenceType is non-mutable and does not have the remove* method has been clear from the start. In *effect*, however, concrete CollectionTypes do have both .removeFirst() and dropFirst().

Replacing .dropFirst() with a “better” verb phrase such as .skipFirst() raises a new concern:

The API Guidelines *could* make Swift 3 users to expect consistency when it comes to mutating/non-mutating pair APIs *wherever applicable*. This is a great goal for a programming language. Taking this away from Array just because it happens to be a SequenceType? That’s Robbery.

- Daniel