# Vector, a fixed-size array

**URL:** <https://forums.swift.org/t/vector-a-fixed-size-array/75264>\
**Category:** Pitches\
**Tags:** array\
**Created:** [October 10, 2024, 1:18am UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264 "2024-10-10T01:18:30Z")\
**Posts on this page:** 20\
**Page:** 5

<div class="post-metadata">

**Author:** ![scanon](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/scanon/32/2445_2.png) [@scanon](https://forums.swift.org/u/scanon)\
**Post date:** [October 11, 2024, 2:51pm UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/83 "2024-10-11T14:51:04Z")

</div>

> [@FranzBusch](#):
>
> I often wanted to reach for a fixed size deque.

A fixed _size_ deque, or a fixed _capacity_ deque? (A fixed-size deque is not very interesting; actually a fixed-size any-container-other-than-array/vector/tuple/whatever-you-want-to-call-it is not very interesting, which is part of why it makes sense to give it a special name: it is in some sense the unique fixed-size container.)

---

<div class="post-metadata">

**Author:** ![FranzBusch](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/franzbusch/32/19447_2.png) [@FranzBusch](https://forums.swift.org/u/FranzBusch)\
**Post date:** [October 11, 2024, 2:52pm UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/84 "2024-10-11T14:52:14Z")

</div>

> [@scanon](#):
>
> A fixed _size_ deque, or a fixed _capacity_ deque? (A fixed-size deque is not very interesting...)

Yes mixed them up. I meant a fixed capacity deque.

---

<div class="post-metadata">

**Author:** ![Nobody1707](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/nobody1707/32/2169_2.png) [@Nobody1707](https://forums.swift.org/u/Nobody1707)\
**Post date:** [October 11, 2024, 3:20pm UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/85 "2024-10-11T15:20:05Z")

</div>

> [@beccadax](#):
>
> If we _do_ want a snappy name, I notice that we still have not decided what exactly a `Buffer` is. Its use in `UnsafeBufferPointer` and friends seems compatible—they are also fixed-size collections of data stored inline at the base address.

For what it's worth, I believe Hylo uses `Buffer` as the name for its fixed sized arrays. Although they seem to be using the C/Java style `T[N]` shorthand, which requires an extra set of brackets for each extra dimension. Whereas `[T; N]` naturally lets you add new dimensions with just a comma, and the `[T * N]` & `[T x N]` forms would just need another multiplication sign.

I don't think we should even consider the shorthands that put `T` after `N`, since it would cause the placement of `T` to move when extra dimensions are added. For this reason, I also think that having the `Count` parameter before `Element` in the definition of `Vector` is wrong because it'll either be inconsistent if we add a fixed sized multi-dimensional array (or when users inevitably write one as a wrapper around a `Vector`) or it'll constrain said multidimensional array to have the element type in the wrong spot.

---

<div class="post-metadata">

**Author:** ![Joe\_Groff](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/joe_groff/32/1929_2.png) [@Joe\_Groff](https://forums.swift.org/u/Joe_Groff)\
**Post date:** [October 11, 2024, 3:29pm UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/86 "2024-10-11T15:29:58Z")

</div>

> [@Nobody1707](#):
>
> I don't think we should even consider the shorthands that put `T` after `N`, since it would cause the placement of `T` to move when extra dimensions are added. For this reason, I also think that having the `Count` parameter before `Element` in the definition of `Vector` is wrong because it'll either be inconsistent if we add a fixed sized multi-dimensional array (or when users inevitably write one as a wrapper around a `Vector`) or it'll constrain said multidimensional array to have the element type in the wrong spot.

Consider what happens when you index a nested construct. If you have `let matrix: [N * [M * T]]` then subscripting `matrix[n]` will index the outer array first, and `matrix[n][m]` will index the scalar element of type `T` from one of the inner arrays. Putting the count before the element type allows the order of nested dimensions to follow the order of successive indices. By a naive grammatical interpretation, syntaxes that put the dimension after the element type would compose the dimensions in the opposite order from how they're indexed; `T[N][M]` naively parses as `(T[N])[M]` and would be indexed by `matrix[m][n]` (same with `[[T * N] * M]` and similar constructs). C, Java, and other such languages special case the parsing of array types to apply the dimensions in backwards order. We could do that, but I would rather have a syntax that "just works".

---

<div class="post-metadata">

**Author:** ![Nobody1707](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/nobody1707/32/2169_2.png) [@Nobody1707](https://forums.swift.org/u/Nobody1707)\
**Post date:** [October 11, 2024, 3:34pm UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/87 "2024-10-11T15:34:13Z")

</div>

But why would we ever index like that when we actually support multi-parameter subscripts? An actual multidimensional array index with the T first syntax would look like:

```Swift
let matrix: [T; M, N] = ...
matrix[n, m] = ...

```

---

<div class="post-metadata">

**Author:** ![Joe\_Groff](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/joe_groff/32/1929_2.png) [@Joe\_Groff](https://forums.swift.org/u/Joe_Groff)\
**Post date:** [October 11, 2024, 3:39pm UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/88 "2024-10-11T15:39:51Z")

</div>

Even if there is eventually a standard multidimensional tensor type in the standard library, developers can and will nest this single-dimension vector type to build up ad-hoc multidimensional structures. And that's fine IMO; the only real motivation to have a separate type that's natively multidimensional would be if that type had a different layout policy from what you get by composing the fixed-size one-dimensional type (maybe it's row-major instead of column-major, or does cache-aware tiling of the elements, etc.)

---

<div class="post-metadata">

**Author:** ![ksluder](https://avatars.discourse-cdn.com/v4/letter/k/eada6e/32.png) [@ksluder](https://forums.swift.org/u/ksluder)\
**Post date:** [October 11, 2024, 4:03pm UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/89 "2024-10-11T16:03:55Z")

</div>

I also strongly prefer that the type comes first. Putting the type last is harder to read due to the pileup of closing delimiters, especially when the types are nontrivial:

```swift
typealias Header = [(tag: Int, values: [(tag: Int, value: String) * 4]) * 3]

// versus

typealias Header = [3 * [(tag: Int, values: [4 * (tag: Int, value: String)])]

```

---

<div class="post-metadata">

**Author:** ![allevato](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/allevato/32/385_2.png) [@allevato](https://forums.swift.org/u/allevato)\
**Post date:** [October 11, 2024, 4:12pm UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/90 "2024-10-11T16:12:31Z")

</div>

IMO, neither of those is an improvement over the other and they would benefit from intermediate types/typealiases. I think they're both equally difficult to grok—the location of the dimension isn't the problem here.

---

<div class="post-metadata">

**Author:** ![fclout](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/fclout/32/36155_2.png) [@fclout](https://forums.swift.org/u/fclout)\
**Post date:** [October 11, 2024, 4:14pm UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/91 "2024-10-11T16:14:53Z")

</div>

Another motivation to have a native multi-dimensional fixed-size array is that the strictly memory-safe Swift compiler could look at you straight in the eye and give you a flattened `Span<T>` representing the entire collection and you could slice it any way that you liked (including in ways that don't respect dimension boundaries), whereas this would probably have to break out of the safe model if we only had nested fixed-size arrays.

---

<div class="post-metadata">

**Author:** ![Joe\_Groff](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/joe_groff/32/1929_2.png) [@Joe\_Groff](https://forums.swift.org/u/Joe_Groff)\
**Post date:** [October 11, 2024, 4:18pm UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/92 "2024-10-11T16:18:24Z")

</div>

That's an interesting point. In previous discussions we've discussed having a protocol to indicate whether a type is a homogeneous aggregate of one element type. That could be used to provide a safe API for turning a pointer/span over one or more instances of the aggregate into a pointer/span of the element type.

---

<div class="post-metadata">

**Author:** ![ksluder](https://avatars.discourse-cdn.com/v4/letter/k/eada6e/32.png) [@ksluder](https://forums.swift.org/u/ksluder)\
**Post date:** [October 11, 2024, 5:20pm UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/93 "2024-10-11T17:20:58Z")

</div>

> [@Joe\_Groff](#):
>
> In previous discussions we've discussed having a protocol to indicate whether a type is a homogeneous aggregate of one element type.

If that’s in the cards, then surely it makes sense to model these as tuples and retroactively synthesize the HomogeneousAggregate conformance in a future runtime version?

Endowing tuples with the ability to describe repeated elements would also give the language a way to describe the memory layout of any nominal type, including classes:

```swift
class C {
  var elts: (Int * 8)
}

print(MemoryLayout<C>.StorageLayout)
// (elts: (Int * 8))

```

---

<div class="post-metadata">

**Author:** ![lorentey](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lorentey/32/1299_2.png) [@lorentey](https://forums.swift.org/u/lorentey)\
**Post date:** [October 12, 2024, 1:37am UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/94 "2024-10-12T01:37:03Z")

</div>

> [@ApolloZhu](#):
>
> I feel like if we have to clarify what a `Vector` is in the title of this pitch, maybe it should just be called `FixedSizeArray`.

"Vector" is an extremely well-established name for an ordered sequence of precisely _n_ items, all of the same type. There is a particularly strong expectation that a type called "vector" would provide an array-like subscript operation. There is an equally remarkable lack of any expectations of resizability: when I see a type called vector, I would not expect it to come with any `insert`, `append` or `remove` operations. The name also rightly discourages operations like concatenation.

The phrase "fixed-size array" is one way to explain the meaning of this term in documentation to someone who has never heard of vectors. Dictionary definitions do not make good names though -- certainly not for something as fundamental as `Vector`.

(I expect we'll soon start discussing a shockingly large zoo of potential array variants besides the current `Array` and `ContiguousArray`, and I fully expect we'll use qualifier prefixes to name them: the prototypes have names like `InlineArray`, `RigidArray`, `SmallArray`, or `DynamicArray`. `Vector` isn't like any of these -- it feels like it is its own thing, far more fundamental than any member of the array family. The `Array` variants all provide roughly equivalent sets of operations, and the naming prefixes directly translate to other container types: it makes perfect sense to define a `RigidDeque` or an `InlineSet`. There appears to be no reason to define a fixed-size `Deque`, or a fixed-size `Set` though -- `Vector` is a unique thing, it isn't establishing a pattern.)

"Homogeneous tuple" is another, equally valid, way to describe/define what a vector is -- indeed, Swift has been importing C's stunted "array" types as homogeneous tuples, and we are hoping `Vector` will substitute for this use. "Tuple" is a great name, but it's very much taken to mean the general type product: types like `(Int, String, Bool)` are what Swift calls a "tuple". Unlike "vector", the term "tuple" strongly implies heterogeneity, and it lacks an expectation of an indexing subscript. (Swift's tuples can be composed of different parts, and these parts are accessed with member syntax, not subscripts.) `HomogeneousTuple` would be a terrible name, for the same reason `FixedSizeArray` would be -- we should not be naming fundamental concepts by their dictionary definitions.

The Standard Template Library in C++ has swapped the names of `std::vector` and `std::array`. As quoted in the proposal, Stepanov himself considers this a mistake. Swift exists to fix the mistakes of C and C++, not to embrace and propagate them.

Luckily, we are already calling our array type `Array`, thanks to our Objective-C legacy. We therefore have a clear opportunity to call our vector type `Vector`. We should take it.

---

<div class="post-metadata">

**Author:** ![lorentey](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lorentey/32/1299_2.png) [@lorentey](https://forums.swift.org/u/lorentey)\
**Post date:** [October 12, 2024, 1:48am UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/95 "2024-10-12T01:48:23Z")

</div>

> [@Nobody1707](#):
>
> For what it's worth, I believe Hylo uses `Buffer` as the name for its fixed sized arrays.

"Buffer" is a great name. Unfortunately, the Swift Standard Library is already using it to mean a very different thing:

> [@SE-0447: Span: Safe Access to Contiguous Storage](https://forums.swift.org/t/se-0447-span-safe-access-to-contiguous-storage/74676/52):
>
> I don't think I've seen this spelt out anywhere, but the stdlib appears to consistently use the term "buffer" to mean a region of memory with unspecified (i.e., client-managed) initialization state. `UnsafeBufferPointer` and `ManagedBuffer`/`ManagedBufferPointer` do not (in general\*) make type-level assumptions on which of their slots contain initialized values -- managing that is entirely outside their mandate, and they expect code that uses them to do custom bookkeeping to prevent misuse. This makes these constructs crucial for building efficient data structures (each of which come with well defined, but incompatible ways of performing that bookkeeping), but it also covers them in a thick layer of ambiguity and danger that makes it wildly inappropriate to use them as a way to exchange or transfer data. I look at the existing types as primarily useful for representing "storage", or data in stasis.

`Vector` is like a fixed-size array; it's like a homogeneous tuple; it's like a fully initialized buffer; it's like an escapable span that has its own inline storage. These are all valid ways to explain what it is; none of these phrases would work well as the name of the type.

> [@1-877-547-7272](#):
>
> It doesn’t conform to AdditiveArithmetic (even conditionally), even though an actual vector type would.

Nothing prevents us from adding a conditional `AdditiveArithmetic` conformance to `Vector`. We did consider adding this; we did not include it in the proposal, but there is nothing specifically preventing this later.

However, note that the stdlib's preexisting "actual" SIMD vector types (`SIMD2`, `SIMD3`, etc) also do not conform to that protocol. This strongly hints at an underlying issue.

I'd be particularly interested in seeing packages that experiment with implementing operators like `+` or `*` (for scaling with a scalar) to `Vector`. There is a real risk that Swift's expression checker is not strong enough to bear such load, and that the compiler will not emit well-optimized code for complex vector expressions -- it would be lovely if we figured out how to resolve these. This experimentation does not need to (and I believe it _really_ should not) start with an evolution proposal.

> [@1-877-547-7272](#):
>
> It’s worth noting that in Swift, `+` is used both [for addition](https://developer.apple.com/documentation/swift/additivearithmetic/+(_:_:)) and [for concatenation](https://developer.apple.com/documentation/swift/rangereplaceablecollection/+(_:_:)-2n67q). That means that if we were to add a `+` operator to `Vector`, then it would likely be pretty confusing.

This is a valid reason not to add a standard `+` operator. (However, note that we do not expect to ever offer an operation to concatenate two vectors -- that is not what vectors are _for_.)

(Reasonable people may also disagree on the meaning of `*`.)

However, this should not prevent packages from experimenting with adding `+` and `*` operators. It also does not prevent `Vector` from providing _named methods_ for forming linear combinations.

> [@dimi](#):
>
> If we wanted to have fun and still wanted a one word name, I would suggest `Shelf` or `Case` — it ain’t growing in size, but it holds a fixed number of items.

> [@ibex](#):
>
> `Row` or `Store` could be alternative type names to consider instead of `Vector`.

These are also great names. They come with a great disadvantage against `Vector`, though: they are brand new names, freshly invented with zero preexisting precedent (that I know of -- although "row" is being used in relational databases, in a context that has nothing to do with `Vector`.). I'd like us to keep them in mind for some _actually novel_ use case in the future.

Even the most vehement critics of the name `Vector` must concede that it hints strongly at the nature of this type: indeed, while C++ mistakenly calls its array type `std::vector`, no actual person is ever seriously confused that we call our (much better) equivalent `Array`. Likewise, no actual person will ever be seriously confused if we called our (much better) `std::array` type `Vector`.

The STL's naming mistake simply reinforces the use of the term "vector" to mean a vaguely array-shaped thing.

> [@1-877-547-7272](#):
>
> If the standard library were to define a type named `Vector`, then that would cause a source break in any module that uses another module’s `Vector` type.

If this argument was valid, it would apply to every new type we ever add to the stdlib. Luckily, its premise isn't true -- names defined locally (or explicitly imported) shadow all names implicitly imported from the stdlib. Any preexisting (or future) local use of the `Vector` type name will continue to resolve to its local definition.

(We've gone through all this with `Result`.)

> [@1-877-547-7272](#):
>
> Additionally, it would discourage library authors in the future from creating their own types named `Vector`, even when that’s the best name for the type.

This is true, but I don't see how this is a negative thing -- part of the job of the Standard Library (of any language) is to establish great names for its fundamental primitives. The stdlib's names are huge part of what defines a language -- it defines the vocabulary of all Swift code.

From what I can tell, the type we're introducing is the best possible use of the name "vector". If someone finds another vector-shaped type, they are more than welcome to name it as such -- they just need to figure out a qualifier that distinguishes it from the stdlib's type.

The stdlib ships with a generic type called `Set` that is based on a very specific variant of hash tables. This is just one possible way to define a useful set, even if we assume that sets are based on hashing. The stdlib naming its type `Set` has indeed discouraged other people from using the name `Set` as is; but it has not prevented us from adding different (sometimes wildly different) set-like types -- we just tend to add qualifiers, like `OrderedSet`, `TreeSet`, or `SortedSet`.

The Standard Library shipping with a `Vector` type will likewise establish a clear direction for naming similar types. (If there are any; `Vector` is certainly going to be difficult to compete with on merits.)

> [@QuinceyMorris](#):
>
> "How about `List`?"

`List` is a great name. All previous usages of it that I've seen (and I've seen quite a lot of them) were resizable, like an array.

(There is also the very prominent usage of the name `List` in SwiftUI. Like it or not, it practically prevents us from ever using this name for a standard container type.)

> [@davedelong](#):
>
> I much prefer `FixedArray`.

That would imply there was something broken with `Array`. There isn't.

> [@Diggory](#):
>
> Total bikeshedding, but how about the name '`RigidArray`'?

In some early drafts, that was indeed the working name for this type. We've moved on from it because we realized `Vector` isn't really an array variant. Early feedback also indicated that the adjective "rigid" has some negative connotations that we do not want to associate with `Vector`.

> [@rauhul](#):
>
> don't have a specific issue with the name `Vector` but I am curious what a future Fixed _Capacity_ Array might be named, and similarly what names we might give other fixed collections, like `{Stack|Queue|RingBuffer}<let Capacity: Int, Element>` etc...

We now use the `Rigid` prefix as the provisional naming convention for the fixed-capacity, but heap allocated array, deque, set variants: `RigidArray`, `RigidDeque`, `RigidSet`, etc. (The negative connotations of rigidity are apt there, as these variants are rather annoying to use in practice.)

---

<div class="post-metadata">

**Author:** ![simonomi](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/simonomi/32/23609_2.png) [@simonomi](https://forums.swift.org/u/simonomi)\
**Post date:** [October 12, 2024, 3:39am UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/96 "2024-10-12T03:39:48Z")

</div>

> [@lorentey](#):
>
> we realized `Vector` isn't really an array variant

What's the reasoning behind this? As far as I can tell, that's _exactly_ what it is (the name of this thread calls it "a fixed-size array"!). It serves the same roll as `Array`, but with some additional restrictions, and thus better performance. For every use case I can think of, `Array` _could_ be used instead, at the expense of performance.

To me, it seems best to treat all these various fixed-count/fixed-capacity/etc types in the same way—as variations of their respective 'base' type.

- `Array`, `FixedCountArray`, `FixedCapacityArray`
- `Dictionary`, `FixedCapacityDictionary`
- `Set`, `FixedCapacitySet`
- `Span`, `FixedCountSpan`
- etc.

---

<div class="post-metadata">

**Author:** ![lorentey](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lorentey/32/1299_2.png) [@lorentey](https://forums.swift.org/u/lorentey)\
**Post date:** [October 12, 2024, 3:47am UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/97 "2024-10-12T03:47:51Z")

</div>

`Vector` isn't an array variant, because it doesn't come with the expected set of array operations. You cannot insert new elements into a vector; you cannot remove any existing items. Array types are range-replaceable containers -- `Vector` is not.

> [@simonomi](#):
>
> `Span`, `FixedCountSpan`

`Span` is already a fixed-count container. There is no such thing as a `FixedCountSpan`. (Just like there is no such thing as a `FixedCountSet`, or a `FixedCountDeque`, or a `FixedCountString`. Adding "static-countedness" does not seem to be a useful way to generate new variants of existing data structures. We do have `StaticString` -- its instances have constant size, but this size isn't part of the type. `Vector` is a brand new thing.)

---

<div class="post-metadata">

**Author:** ![simonomi](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/simonomi/32/23609_2.png) [@simonomi](https://forums.swift.org/u/simonomi)\
**Post date:** [October 12, 2024, 3:58am UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/98 "2024-10-12T03:58:52Z")

</div>

> [@lorentey](#):
>
> `Span` is already a fixed-count container

Oh right, of course 🤦‍♀️. I guess I was imagining having the count be stored in a generic parameter, but there's not really a big difference there.

For some reason, despite `Vector` not having all the same array operations, it still 'feels' like the same kind of thing to me. Every other different data structure adds something new: `Dictionary` has key-value pairs, `Set` is unordered and without duplicates, and so on. But `Vector` has a _subset_ of `Array`'s capabilities, with the same kind of subscript, indices, and iteration. The only significant difference I can think of is being stored inline, which I don't think merits being its own separate kind of data structure.

---

<div class="post-metadata">

**Author:** ![lorentey](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lorentey/32/1299_2.png) [@lorentey](https://forums.swift.org/u/lorentey)\
**Post date:** [October 12, 2024, 4:33am UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/99 "2024-10-12T04:33:36Z")

</div>

> [@simonomi](#):
>
> For some reason, despite `Vector` not having all the same array operations, it still 'feels' like the same kind of thing to me.

I think this is a useful feeling, but consider that `Array` is actually quite far away from `Vector` -- we have types in the stdlib that are far closer!

The existing type I most associate with `Vector` is `Unsafe[Mutable]BufferPointer`. The new `Span` type that is currently under review is even closer; the `MutableSpan` type we're drafting will be even closer still. None of these types carry the word "array" anywhere in their names.

`Vector` is part of a family of fundamental low-level types, all forming vaguely similar shapes: they are all fixed-size containers; they all have integer indices; they share much of their core API, and they are all backed by a single contiguous memory region. Their contents are mutable (as long as we have mutating access), but their structure is not: they do not support resizing. There are very strong commonalities between them, but they are all special in some unique way. They all feel like fundamental constructs that will play extremely prominent roles.

These types are all modeling different aspects of the concept of a "memory region" -- this is such an important concept, it appears it cannot be captured by just a single type!

We do not intend to replace the great name `Span` with an absurdly bad name like `NonescapableFixedSizeArray`. `UnsafeBufferPointer` isn't a great name, but `UnsafeFixedSizeArrayWithPotentiallyUninitializedElements` would be so much worse!

The similarity of `Vector`/`Span`/`UnsafeBufferPointer` to `Array` is helpful when explaining these types, but it’s entirely superficial, and we should not over-emphasize it. Vectors, spans, buffers aren't arrays -- we should not call them that.

I promise: the name `Vector` will grow on you. All great names do!

---

<div class="post-metadata">

**Author:** ![ibex](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ibex/32/30439_2.png) [@ibex](https://forums.swift.org/u/ibex)\
**Post date:** [October 12, 2024, 5:21am UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/100 "2024-10-12T05:21:44Z")

</div>

> [@lorentey](#):
>
> I promise: the name `Vector` will grow on you. All great names do!

Not only that, it so smoothly rolls off the tongue: saying `Vector`. 🙂

---

<div class="post-metadata">

**Author:** ![lorentey](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/lorentey/32/1299_2.png) [@lorentey](https://forums.swift.org/u/lorentey)\
**Post date:** [October 12, 2024, 7:20am UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/101 "2024-10-12T07:20:55Z")

</div>

> (re: `RigidArray`) In some early drafts, that was indeed the working name for this type.

(Fun anecdote: the moment that turned our draft `RigidArray` type into a bona fide vector was particularly noteworthy. In the early days, we planned our precursor type to be unconditionally noncopyable — until one particularly memorable & productive engineering discussion, where we decided that it needs to become conditionally copyable (despite the immense extra complexity this adds to its implementation).

That very same day, two separate groups of people independently realized that copyability has now turned this type into a true vector, and that `Vector` is the obviously right name for this construct. This made for a comical scene when members of the two groups met up later in the day, fully expecting that they’d need to convince the other.

This was the only time I ever experienced such a naming miracle; I do not expect it to ever see it happen again. It has left me with a rock solid conviction that `Vector` is the right name for this shape — I feel it deep in my bones, and it would take quite some effort to convince me otherwise.

In contrast, the name `Span` was a very difficult birth — it took months of diligent effort to convince people about it. The type’s mediocre (at best) working titles have even made it into some formal pitch documents!)

---

<div class="post-metadata">

**Author:** ![jberry](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jberry/32/6360_2.png) [@jberry](https://forums.swift.org/u/jberry)\
**Post date:** [October 12, 2024, 7:46pm UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/102 "2024-10-12T19:46:41Z")

</div>

> [@lorentey](#):
>
> `Vector` is part of a family of fundamental low-level types, all forming vaguely similar shapes: they are all fixed-size containers; they all have integer indices; they share much of their core API, and they are all backed by a single contiguous memory region. Their contents are mutable (as long as we have mutating access), but their structure is not: they do not support resizing. There are very strong commonalities between them, but they are all special in some unique way. They all feel like fundamental constructs that will play extremely prominent roles.

As people seem interested in how names of related types fit together and describe those types, and since it sounds like you have a strong inclination of what those future related types should be, can you spitball the names of the members of this family to show how you anticipate the naming of the family tree will fallout? So far, we’ve got Vector.

[Previous page](https://forums.swift.org/t/vector-a-fixed-size-array/75264.md?page=4)

[Next page](https://forums.swift.org/t/vector-a-fixed-size-array/75264.md?page=6)
