[swift-evolution] [Proposal] Enum subsets

Matthew Johnson matthew at anandabits.com
Sat Jun 4 07:00:57 CDT 2016



Sent from my iPad

> On Jun 4, 2016, at 12:34 AM, Austin Zheng via swift-evolution <swift-evolution at swift.org> wrote:
> 
> It seems like it would make sense to model enum subsets as a subtype relationship.
> 
> Is the core team planning on drawing up a structs/enums subtyping proposal later this year?

+1.  Subtype relationship is mostly what is desired here.  

Some people have also talked about members of the supertype also being available on the subtype which would involve implementation inheritance.  That could probably be made to work for enums if the subtype receives identical storage and as long as all supertype members are considered final (because value type members are always final).  But it's a slippery slope and would likely bloat the storage of many subtype enums.

-Matthew

> 
> Austin
> 
>>> On Jun 3, 2016, at 10:25 PM, Chris Lattner <clattner at apple.com> wrote:
>>> 
>>> 
>>> On Jun 3, 2016, at 2:35 PM, T.J. Usiyan via swift-evolution <swift-evolution at swift.org> wrote:
>>> 
>>> Since this seems to have some interest, I've made a gist.
>>> 
>>> https://gist.github.com/griotspeak/963bc87a0c244c120264b11fb022d78c
>> 
>> We have frequently discussed introducing subtype relationships between structs and enums, in an effort to allow limited implicit promotions (e.g. from small integers to wider integers).  Wouldn’t that be a more general solution to this same problem?
>> 
>> -Chris
> 
> _______________________________________________
> 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/20160604/c57d06a0/attachment.html>


More information about the swift-evolution mailing list