<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>As previosly state there is one problem using tuples as rawValues - they currently must be static (literals) and unique. In example with planets the mass or radius is not unique so it cannot be used as raw value with current requirments. <br><br><br></div><div><br>On 28 May 2016, at 20:22, Leonardo Pessoa <<a href="mailto:me@lmpessoa.com">me@lmpessoa.com</a>> wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div><div style="font-family: Calibri,sans-serif; font-size: 11pt;">My suggestion of allowing tuples as raw values instead doesn't burden the language and also does not eliminate rawValue (treat previously supported raw value types as one value tuples), reads very cleanly and supports a syntax we're already familiar with. I don't see how the 'where' syntax reads like natural language and I agree it doesn't match other uses of where in the language.<br><br></div></div><div dir="ltr"><hr><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">From: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:swift-evolution@swift.org">Jānis Kiršteins via swift-evolution</a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Sent: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;">28/05/2016 10:54 AM</span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">To: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:brent@architechies.com">Brent Royal-Gordon</a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Cc: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:swift-evolution@swift.org">swift-evolution</a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Subject: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;">Re: [swift-evolution] [Proposal] Enums with static stored propertiesfor each case</span><br><br></div>> - Abusing rawValue is just that: an abuse.<br><br>My original proposal does not replace rawValue and is compatible with it.<br><br>> - Using `where` just doesn't match the use of `where` elsewhere in the language; everywhere else, it's some kind of condition.<br><br>It is also used in generic type constraints. Plus it reads like human<br>language: `case mercury where (mass: 3.303e+23, radius: 2.4397e6)`<br><br>> - Dictionaries are the most straightforward way to handle this with the current language, but their lack of exhaustiveness checking is a problem.<br><br>Dictionaries can be used as workaround, but they cannot (lack of<br>exhaustiveness) solve the problem.<br><br>> What I would do is borrow the "accessors" concept from the property behaviors proposal and extend it so that it supported both functions and variables.<br><br>Wouldn't accessor just be a redundant keyword here? Currently enums do<br>not support stored properties, so I guess there is no extra need to<br>mark properties with any special keyword.<br><br>Property accessors might work for enums with associated values, but<br>not so well without them.<br><br>On Fri, May 27, 2016 at 3:43 PM, Brent Royal-Gordon via<br>swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>>> The suggested solution based on 'accessor' - will create assotiated properties each time the enum instace created, for each instance of enum type.<br>><br>> No; property accessors would be either computed or constant (so that all instances of a given case can share storage). This is much the way they would behave if they were included in behaviors.<br>><br>> You could write a property accessor with a setter, but it would have to be computed, and manipulate `self`'s cases and associated values:<br>><br>> enum Optional<T> {<br>> accessor var unwrapped: T { get set }<br>><br>> case none {<br>> unwrapped {<br>> get { fatalError("No value") }<br>> set { self = .some(newValue) }<br>> }<br>> }<br>> case some (_ value: T) {<br>> unwrapped {<br>> get { return value }<br>> set { self = .some(newValue) }<br>> }<br>> }<br>> }<br>><br>> --<br>> Brent Royal-Gordon<br>> Architechies<br>><br>> _______________________________________________<br>> swift-evolution mailing list<br>> <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></body></html>