[swift-evolution] [Pitch] Array full proposal

Daryle Walker darylew at mac.com
Wed Jul 12 23:27:07 CDT 2017


— 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com 

> On Jul 12, 2017, at 4:30 PM, Gor Gyolchanyan <gor at gyolchanyan.com> wrote:
> 
> I agree, given the current state of Swift, fixed-sized arrays are way too magical.

Any more “magical” than the existing primitive types?

> I’d suggest postponing the idea of fixed-sized arrays (even though I myself have ached for them for a long time now) until its prerequisites are met.
> 
> There are three language features that have been discusses before that are required for this:
> Variadic generic parameters.
> Tuples as nominal types with a variadic generic parameter and a tuple concatenation ability.
> Non-type generic parameters (probably, only compile-time value types).

Improved generics would synergize with fixed-size arrays, but are not a prerequisite.

Wouldn’t nominal tuples be structures? Not that it matters here since FSAs aren’t quirky tuples. (I mentioned in the proposal that no language that I know of does this; homogenous and heterogenous product types are always distinct kinds of types.)

> In these terms, a fixed-sized array would be a type that takes an Int as a generic parameter and uses a variadic tuple for its storage. If C++ templates has taught us anything is that metaprogramming can be used for achieving fantastic compile-time wizardry, like converting a single integer generic parameter and a single generic type parameter  to a generic homogeneous variadic type parameter (by using a recursively defined variadic parameter dummy type).

I thought Swift was to avoid that kind of wizardry. And unless you don’t want any of the optimizations array operations get, then the compiler has to analyze tuple types to trigger “array mode."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170713/9922acb7/attachment.html>


More information about the swift-evolution mailing list