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

Félix Cloutier felixcca at yahoo.ca
Wed Jul 26 11:28:37 CDT 2017

Right now, it's marked as "maybe" in the generic manifesto <https://github.com/apple/swift/blob/master/docs/GenericsManifesto.md#generic-value-parameters>.

> There are a number of features that get discussed from time-to-time, while they could fit into Swift's generics system, it's not clear that they belong in Swift at all. The important question for any feature in this category is not "can it be done" or "are there cool things we can express", but "how can everyday Swift developers benefit from the addition of such a feature?". Without strong motivating examples, none of these "maybes" will move further along.


> Le 24 juil. 2017 à 10:06, David Sweeris <davesweeris at mac.com> a écrit :
> On Jul 24, 2017, at 9:37 AM, Chris Lattner via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> On Jul 23, 2017, at 4:27 PM, Félix Cloutier <felixcca at yahoo.ca <mailto: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.
> Is there really any doubt that we'll eventually get Variadic Generics and Non-Type Generic Parameters? They're always well-received whenever they come up, but they keep getting ruled out-of-scope before a proposal can be fully fleshed-out. I'm asking because it'd make it way easier to design a FSA proposal knowing that it could rely on those features. Personally, I'd even be ok with accepting such a proposal "pending the acceptance of its 'dependency proposals'" (with probably a quick re-review to make sure any subsequent proposals haven't materially changed how it'd work).
> - Dave Sweeris

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

More information about the swift-evolution mailing list