Hi all,

Today I made a mistake trying to use .dropFirst() to remove an array element 
in-place. I have the feeling that I will second-guess myself the next time.

IHMO, now that dorpFirst() is no-longer a free function, it's name is hardly 
distinguishable from .removeFirst(). When compared side-by-side, .dropFirst()  
does seem to suggest “return the rest". But this subtlety is easily lost for 
users who don’t use both on regular bases. It’s worse for non-native English 
speakers.

Looking at a few other languages that provides a .dropFirst() for their 
list/array/sequence:

* Haskell’s “tail" only makes sense when paired with “head" (and not that 
self-explanatory). 
* Rust doesn’t have a direct counterpart, but split_first() return both head 
and tail in a tuple.
* Scala and Ruby has a .drop(), but there’s no equivalent of .removeFirst() to 
cause confusion.


There must be a better name for this important method. I came up with:

.dropFirst() => .excludeFirst()

What do y’all think?

(Everything above applies to .dropLast())

- Daniel
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to