[swift-evolution] [Pitch] New Version of Array Proposal

John McCall rjmccall at apple.com
Tue Aug 1 18:21:46 CDT 2017


> On Aug 1, 2017, at 5:49 PM, David Sweeris via swift-evolution <swift-evolution at swift.org> wrote:
>> On Aug 1, 2017, at 10:54 AM, Daryle Walker via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> A tuple can have its members initialized in piecemeal and still satisfy deterministic initialization. The named types need to do all their sub-objects' initializations before any designated initializer ends. I want the former for array instances, not the latter. It’s important for numeric applications, so math arrays don’t have to be set twice, once for an arbitrary default and again for the real data.
> 
> Eh? What do you mean by "initialized in piecemeal"? These both give errors:
> let x:(Int, Int) = (0) // something about not being able to convert `Int` to `(Int, Int)`
> let x:(Int, Int) = (0, _) // something about "_" only being allowed in patterns
> 
> Is that what you're talking about?

I think he means that you can do

var x: (Int,Int)
x.0 = 0
x.1 = 1

This is generally not allowed for other aggregates outside of initializers.

John.


More information about the swift-evolution mailing list