[Second review] SE-0483: `InlineArray` Type Sugar

It's not valid syntax, but that's just because nobody figured out how to make it compile. Conceptually, (Key, Value) and (key: Key, value: Value) are Key: Value for anything that uses ExpressibleByDictionaryLiteral, even though the language can't use the more descriptive form.

Regardless of how you feel about that, the "[]" enclosing [Key: Value] and [(key: Key, value: Value)] represents a collection of some kind of type. The proposed syntax doesn't continue with that concept. Getting caught up on this discussion has made me realize how confusing this is. E.g.

[Int] is a collection whose elements are all instances of Int.
[n of Int] is not a collection whose elements are all instances of "n of Int".
I get that it's short, but it's inconsistent, and doesn't hold up to explanation. This goes for all the "x" forms as well, which I previously didn't think were as bad as I do now, after putting more thought into it.

Here's my take on a better solution:

[Int]<5> // [5 of Int]
[[Int]<5>]<5> // [5 of [5 of Int]]
let fourBytes: [Int8]<_> = [1, 2, 3, 4] // [_ of Int8]
let fourIntegers: [_]<_> = [1, 2, 3, 4] // [_ of _]

I searched; at least one other person had the same idea, and got s'm'upvotes.

3 Likes