[Pitch] InlineArray type sugar

That’s already the case, since you can declare integer generic parameters.

2 Likes

@Slava_Pest @xwu

If you have a few minutes to spare, could you explain what you mean and elaborate a bit?
When you say “the count of inline array not always an integer literal” do you mean, “literal of another type” (i.e tuple) or “not a literal”?

Thanks.

The count of the array here is not a literal for example so any syntax for a sugared type would need to handle this case and not just something like 5:

func f<let n: Int>(_: InlineArray<n, Int>) {}
3 Likes

@Slava_Pestov Thank you very much for your answer. “Literal” was not the right terminology. Let’s just “number” instead. In a purely hypothetical case the [n: T] gets adopted, why would it be confused with a dictionary literal (which, according to the “Alternatives Considered” part of the pitch was rejected “: is of course ruled out as it is used for dictionary literals)? If it’s used as a type :, there’s no confusion, and if it is on the right side of = then again - it is not a valid dictionary literal (as far as I am aware, but if there are some edge cased, I’d be grateful to be educated). So, why “ : is of course ruled out as it is used for dictionary literals.” is it a reason to rule : out?

Correct me if I am wrong, but there would not be a problem with : syntax in your example.

For one, [_ : _] cannot both mean Dictionary<_, _> and InlineArray<_, _>.

5 Likes

Thanks. Now it is clear.

A post was merged into an existing topic: SE-0483: InlineArray Literal Syntax

This proposal is now under review as SE-0483.

1 Like