Hi 00buggy00 -- can you clarify what you mean by "Swift feel"? You use that term in a few places, but other than Vector4<Float>
, you don't really offer any alternatives of what you think would have more "Swift feel", so it's a little bit hard to see what you're getting at.
To me, Vector4<Float>
vs Float.Vector4
is basically "colour" vs "color". Neither feels especially more "Swift" to me--one is the free spelling and the other the member spelling. "Swift" for me is more about what the language lets you do and the safety that it gives you. simd_float4
is not-very-swift, because it doesn't follow the conventions and doesn't enable generic code.
The reason I personally prefer Float.Vector4
is that it's not fighting the language; I don't mind the extra boilerplate, but I think that we should encourage styles that minimize the boilerplate for users who copy the style of the standard library in their own code. With the language as it stands today, that makes me lean towards Float.Vector4
. If you all feel really strongly about Vector4<Float>
, I'm OK with that, but I hope that you'll push just as hard for the language features that would actually make that the natural spelling.
As mentioned before, there is no information that Vector4<Float>
has but Float.Vector4
does not. Both types know that they have precisely 4 elements. These are essentially equivalent formulations. It is OK to prefer one or the other on style grounds, but many of the arguments that I've seen advanced claim that one lets us do something that the other does not. I am yet to see any example where this is actually the case.
In this case, the count
property is still useful in both instances to enable writing code that is generic over vector length. It exists because over the course of a few months writing code against prototypes of this proposal, I found that it was necessary.
Ditto subscripting. It is not a vestigial limb of Collection
, but rather a key escape valve for writing real code. Absent Collection
conformance, count
and subscript
are the tools we have to iterate over a vector. To some extent this can be addressed by adding variants of map
and reduce
for these types, but these two operations would still be necessary.
This is, AFAIK, the first concrete example of something that is actually simpler using the Vector4<Float>
model that anyone has put forward, and is well worth consideration. Thank you.