But it is very likely that many standard functions that accept arrays, will be overloaded to InlineArrays. What will happen in that case, if Array and InlineArray literals have the same form? ([a,...]). Won't it make the type checker confused sometimes, as well as introduce some other unexpected behaviors?
For example, if we overload + operator on InlineArrays with
func + (lhs: InlineArray<n, Element>, rhs: Array<m, Element>) -> Array<m + n, Element> (after the arithmetic in generic parameters gets implemented, or let's assume we've introduced these overloads for small values of n and m manually) - won't the code that worked fine when concatenating arrays suddenly start breaking every time there is some sort of ambiguity between Array and InlineArray? (overloading + was the first thing came to my mind, I am sure there are more interesting use cases).
I understand that, I was just pointing out that if we want to be "consistent", InlineArray typealias should "match" the syntax for InlineArray literals, the syntax for typealiases for Array and Dictionary matches the syntax for literals of these types. Otherwise it might create even more confusion. Some of my comments were under the condition that syntax for array literals might change.
Could you elaborate a bit? I am not sure I completely understand you. Does it mean that examples in SE-0453 like
let a: InlineArray<_, Int> = [1, 2, 3] // InlineArray<3, Int>
let b: InlineArray<3, _> = [1, 2, 3] // InlineArray<3, Int>
let c: InlineArray<_, _> = [1, 2, 3] // InlineArray<3, Int>
let d: InlineArray = [1, 2, 3] // InlineArray<3, Int>
func takesGenericInlineArray<let N: Int>(_: InlineArray<N, Int>) {}
takesGenericInlineArray([1, 2, 3]) // Ok, N is inferred to be '3'.
are not supposed to compile in the future, becuase InlineArray can't conform to ExpressibleByArrayLiteral, or they will compile despite [1, 2, 3] being an array literal, because the literal syntax is hacked in.?
I guess you've meant the "will compile despite..." (please correct me if my guess was wrong).
Assuming this is the case you still have a lot of expressions of form [a...] with ambiguous meaning. Also, if this is a "literal syntax hacked in" - are you certain it will not create more issues later, especially if ExpressibleByArrayLiteral can't be easily fixed to make InlineArray to confirm to it? What will happen if ExpressibleByInlineArrayLiteral gets introduced, and you want you a type to conform to both?
To put it short - won't a many expressions of form [// elements ] with ambiguous meaning cause unexpected problems even with old source code that worked fine?
I assume (I might be wrong again) that InlineArray will be built-in first types and not a part of some library. The problem is that the usages of these types have significant overlap (hence most of standard library functions that work with arrays are supposed to get overloaded for these as well and will become a part of the default namespace) and literals of these types look exactly the same. Not to mention it might create more confusion on the surface.
With new code - it might become even worse. What happens if you have an overloaded code for Array<T> and InlineArray<3, SomeType> (it is natural, since immutable Array of fixed size and immutable InlineArray of the same type are essentialy the "same thing" - differences are implementation details, and you'd like to have the logic to work for both.
When you call `someFunction([a, b, c]) which one will be called?
Let's assume that Array overload is called in this case. Logic is essentially the same and no damage done (probably).
What happens if one overloads a function or initializer for the case when the number of elements is known (And logic benefits from knowing it at compile time) and other for the case when it is not known, using completely different logic? What happens now?
May be I am late to the party (I didn't follow to SE-0453 discussion, and this discussion should continue there, even though it has been accepted) and may be I am just wrong. But even if we assume that there is no problem with type checking performance, which I believe requires further investigation (what happens if we introduce the "natural overloads and protocol conferences for InlineArray into the default envirounment namespace while still using [ //elements ] as the syntax both for Array and InlineArray literals" , the ambiguity of using the same literal syntax for different (as types) but very similar in their usage built-in types might cause a lot of unnecessary clashes in the future. I am sure that all the potential issues mentioned here might have (sometimes very easy) workarounds, but why not avoid them in first place by using (slightly) different syntax for Array and InlineArray literals?
May be we should take a step back, make sure that InlineArray elements don't require different syntax for their literals, change it if needed - and the come back to discussing the syntax for typealias?