[swift-evolution] Proposal: Contiguous Variables (A.K.A. Fixed Sized Array Type)

Chris Lattner clattner at apple.com
Fri Jan 29 11:32:36 CST 2016


> On Jan 29, 2016, at 1:01 AM, Tino Heth via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Damn, I'm way to slow writing proposals…
> 
> I have one big problem with using tuples as basis for fixed-size vectors:
> They cannot have methods, and I want a matrix-type to have some of those.

If we go with this design, the canonical way to do that is as a struct wrapping a tuple, something like:

struct Matrix4x4 {
  private var elements : (4 x (4 x Float))

  public func …
}

This seems like a nice way to handle it, keeping the balance of not adding a completely new fundamental type to the language to solve such a narrow case.

-Chris

> 
> Have a look at
> https://github.com/SwiftTypesafeCalculations/Home/wiki/compile-time%20parameters
> if you want to see what I'd prefer instead — hopefully, I can spare an hour or two today to finish the text.
> 
> Tino
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list