> On Jul 13, 2017, at 7:09 AM, Gor Gyolchanyan <[email protected]> wrote: > > Yes, by nominal tuples I did mean a struct definition somewhere in swift’s > standard library. > > Seems like there are some quirks to tuples in Swift that I’m not aware of. I > always assumed that they are packed ordinary structures. Since structure > member offset is a compile-time constant, using tuples for arrays would not > really be bad for performance, unless I’m missing something.
I’ve been looking at the ABI documents. Structures and tuples can be packed ordinary product types, like in C. But the Swift people want to reserve the right to do extreme rearrangements, like packing bitwise-smaller members between the spacing of the larger ones. (This would mean later-declared sub-objects won’t necessarily have their addresses in increasing order.) Tragically, the current need for tuples to have an “array mode” would block this optimization. Having fixed-size arrays as a separate primitive would allow tuples to have tuple-specific optimizations and arrays to have array-specific optimizations without relying on implementation conventions. > The C++ style compile-time wizardry is a subpar solution because it’s a hacky > workaround due to lack of proper compile-time tools. If Swift would some day > gain ability to execute imperative metaprogramming code that would manipulate > the types at compile-time, all problems of this sort would be solved forever. > But depending on how Swift compiler is implemented that may or may not be a > monumental endeavor. Since arrays (I think) pre-date functional programming, generics, meta-programming, and other “modern” language features, requiring those features as prerequisites for arrays seems weird. — Daryle Walker Mac, Internet, and Video Game Junkie darylew AT mac DOT com _______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
