Simd vector types

The examples you named in Collection APIs are different.

  • swapAt has suffix at, which strongly indicates that the object is one of the elements.
  • sort's object can be the collection itself, and it also strongly indicates its operating on elements because those are the only things you can sort. I would not object it if you introduce a sort() method on Vector.
  • first on Collection strongly indicates that its an element from
    • its type signature Element, and
    • the fact that you can only take the first from elements

x.replacing(with:selectedBy:) does not indicate the object its replacing at all. It can mean both "replacing self" and "replacing elements". The user has to see the second argument label to realize that it might be selecting elements, and it's simply unclear.

2 Likes