[swift-evolution] Allowing enum extensions to also be able to expand case options
Guillermo Peralta Scura
gperaltascura at gmail.com
Thu Jun 30 15:13:34 CDT 2016
I think we have the same question as with the "sealed" classes by default
proposal. To allow or not extension of the public API by the user (at least
by default).
El jue., 30 jun. 2016 a las 16:10, Edward Valentini via swift-evolution (<
swift-evolution at swift.org>) escribió:
>
> Existing switch statements would have to be modified to add a default
> statement. Additionally enums could be marked final to disallow case
> option expansion
>
>
>
> On Jun 30, 2016, at 16:04, David Sweeris <davesweeris at mac.com> wrote:
> >
> > By itself, this would break switch statements, since they have to be
> exhaustive.
> >
> > If anyone has any ideas about how to fix that, I'm all ears.
> >
> > - Dave Sweeris
> >
> >> On Jun 30, 2016, at 14:58, Edward Valentini via swift-evolution <
> swift-evolution at swift.org> wrote:
> >>
> >>
> >> I am finding myself in a situation where the most elegant "swifty"
> solution would be to allow enum extensions to add to existing case
> options. For example lets say I'm using a library that has the following
> enum defined:
> >>
> >> enum MyDirection {
> >> case east, west
> >> }
> >>
> >> My app for example also makes use of north and south, so I would love
> to be able to write:
> >>
> >> extension MyDirection {
> >> case north,south
> >> }
> >>
> >> In objective c, one would probably have defined constants like
> MyDirectionEast etc... these would probably have been mapped to ints or
> strings so a consumer of this library could have easily extended this to
> add additional functionality, but using constants like that is not very
> "swifty"
> >>
> >> I'm curious what the swift community thinks.
> >>
> >> Thank you
> >> _______________________________________________
> >> swift-evolution mailing list
> >> swift-evolution at swift.org
> >> https://lists.swift.org/mailman/listinfo/swift-evolution
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160630/126c6799/attachment.html>
More information about the swift-evolution
mailing list