[swift-evolution] [Proposal] Enum subsets

Chris Lattner clattner at apple.com
Tue Jun 7 22:49:03 CDT 2016

On Jun 5, 2016, at 8:24 PM, T.J. Usiyan via swift-evolution <swift-evolution at swift.org> wrote:
> Sub typing is the answer that we're going with then?

Most likely.  At this point, we’re not really accepting additive changes to Swift 3 anyway, so any proposal would need to wait until post-swift 3 in any case.  

Plans for releases beyond Swift 3 haven’t been made yet - the metaplan is to come up with a plan in ~August timeframe.


> On Sat, Jun 4, 2016 at 4:26 PM, T.J. Usiyan <griotspeak at gmail.com <mailto:griotspeak at gmail.com>> wrote:
> It could be a more general solution. I am unclear about what 'subtype relationships' means here though.
> Are you talking a about what you allude to here? https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151130/000525.html <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151130/000525.html> 
> The benefit of explicitly narrowing, in my opinion, is that there is no unnecessary cost to figuring out lookup. (Please correct me if I am mistaken.) Implicit promotions introduce uncertainty with regard to what a value is being treated as in any given moment. This uncertainty is worth it in many cases but I will suggest that it is not worth it when trying to deal with a narrower set of cases from an already established set. For example, in the graph/lattice situation, conversions must be written because there is no reasonable conversion that can be assumed. In this proposal, the conversion is obvious and trivial because the relationship is completely clear.
> All of that said, I *am* unclear about what subtype relationships means so it may very well be a better solution. It certainly sounds like a more general solution but I am not convinced that that is an advantage when trying to deal with a strict subset.
> TJ
> On Sat, Jun 4, 2016 at 1:25 AM, Chris Lattner <clattner at apple.com <mailto:clattner at apple.com>> wrote:
>> On Jun 3, 2016, at 2:35 PM, T.J. Usiyan via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> Since this seems to have some interest, I've made a gist.
>> https://gist.github.com/griotspeak/963bc87a0c244c120264b11fb022d78c <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/20160607/43c29954/attachment.html>

More information about the swift-evolution mailing list