[swift-evolution] [Proposal] Enum subsets
griotspeak at gmail.com
Sun Jun 5 22:24:34 CDT 2016
Sub typing is the answer that we're going with then?
On Sat, Jun 4, 2016 at 4:26 PM, T.J. Usiyan <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?
> 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.
> On Sat, Jun 4, 2016 at 1:25 AM, 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.
>> 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?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution