[swift-evolution] [RFC] Definitive Initialization and Incompatibilities with Fixed-size Arrays

Chris Lattner clattner at nondot.org
Mon Jul 24 11:37:39 CDT 2017


> On Jul 23, 2017, at 4:27 PM, Félix Cloutier <felixcca at yahoo.ca> wrote:
> 
>>> 
>>> Well, fixed-size arrays don’t have initializers, for the same reason tuples don’t: they’re compound types instead of named types and they literally have nowhere to place initializer definitions. But like tuples, FSAs have a literal syntax that works as a substitute for full-blown initializers.
>> 
>> Ok, sure.  They aren’t literally initializers in the stdlib (they are built into the compiler), but they have initialization semantics and can be spelled in whatever way makes ergonomic sense.  Keeping them aligned with Array seems like a good starting point.
> 
> Either way, in the context of fixed-size arrays, I think that it's a broader problem that anonymous types can't have anything attached to them. This also prevents fixed-size arrays from conforming to protocols, even Sequence, and Swift would need variadic generics or (possibly, depending on the syntax) non-type generic parameters to even create a wrapper.

Agreed. However, solving that general problem is hard, and completely orthogonal to the win of having fixed sized arrays work.

-Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170724/e54939c4/attachment.html>


More information about the swift-evolution mailing list