[swift-users] Why does RangeReplaceableCollection require an empty initialiser?

Austin Zheng austinzheng at gmail.com
Wed Jul 6 21:31:24 CDT 2016


Would this require a swift-evolution review, since it's technically an API
change? (removing the initializer requirement is something I am also
interested in seeing...)

Austin

On Wed, Jul 6, 2016 at 7:05 PM, Dave Abrahams via swift-users <
swift-users at swift.org> wrote:

>
> on Wed Jul 06 2016, Tim Vermeulen <swift-users-AT-swift.org> wrote:
>
> > RangeReplaceableCollection has three initialisers: init(), init(_:)
> > and init(repeating:count:). The latter two are implemented using the
> > empty initialiser. But why are these initialisers part of this
> > particular protocol? As far as I can tell, no other methods of this
> > protocol depend on these initialisers. The requirement of the empty
> > initialiser makes it impossible to have a collection conform to this
> > protocol that needs additional data for its initialisation.
>
> This is an excellent point, and I think it may have been an oversight
> that we made this a requirement.  Please open a bug and/or file a radar.
> https://bugs.swift.org/secure/Dashboard.jspa
>
> Thanks!
>
> > For instance, I was making an array that works with any Strideable
> > indices, not just integers. A startIndex is needed for its
> > initialisation, so I can’t really conform it to
> > RangeReplaceableCollection. If I do it anyways (with a fatalError() in
> > the required empty initialiser) everything seems to work just fine,
> > except for the protocol’s three initialisers.
> >
> > Perhaps these initialisers should be moved to a (possible new)
> > different protocol?
>
>
> --
> Dave
>
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160706/251be1b6/attachment.html>


More information about the swift-users mailing list