What is the Protocol
suffix adding here? The default would be Vector
, IntegerVector
, and FloatingPointVector
--what ambiguity do we need to resolve by deviating from it?
Sure. Array<Element>
is the 99.9% case, but this is easy to add.
Sequence conformance is something that we could consider adding in a follow-on proposal.
Subscripting is a necessary escape valve for writing some code, but generally not the bread-and-butter of the SIMD programming model. Re-using an index is especially rare. The primary use is either a literal index (which could be checked at compile time as-is), or iterating through the elements in order. Being able to do arithmetic on indices, however, is a very nice convenience, so we'd end up with at least ExpressibleByIntegerLiteral & Numeric
, which is basically ... integers. So this feels like a bunch of machinery for not a whole lot of gain.
any
and all
are by far the most common operations that you do on SIMD masks. Because they're used all the time, using shorter names makes sense. allSatisfy
is a much less commonly-used operation on generic Collections
. any
and all
are also the names used for these in every compute language, so there's a huge amount of precedent for them.
Note that people tend to use these directly on comparison results, rather than assigning them to variables first. So your example would become:
guard (x .>= 0).allSatisfy(true) else { /* ... */ }
vs.
guard all(x .>= 0) else { /* ... */ }
The latter reads far more naturally to me. This is partially a matter of taste, but I doubt that I'm the only who finds this to be the case. I should note that, while we want to conform to the norms of Swift, a huge selling point of the simd module on Apple platforms in C and C++ has been that it hews closely to compute language conventions. This makes it much easier to write similar code for CPU and GPU, and marshal data structures. This proposal backs away from that position somewhat in the name of conforming to the norms of the Swift language, but there's a lot of value in not throwing it away entirely, especially w.r.t. the naming of core free functions like these.