<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 10 Oct 2016, at 13:04, Mateusz Malczak via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">I think, I have used quite unfortunate naming, which is a root of an<br class="">misunderstanding here. By saying 'enums with stored properties' what I<br class="">was really thinking about, was enumeration type with stored constant,<br class="">immutable properties (constants). I don't want to duplicate 'struct'<br class="">type here, but instead I would like to make it possible to store a<br class="">const values in enumeration cases. So going back to my example once<br class="">again:<br class=""><br class="">Lest define an enumeration type `Format` with 3 possible cases. Each<br class="">case will be able to carry over some additional information - in this<br class="">case a pair of numbers (but in fact Any? should be possible)<br class=""><br class="">enum Format {<br class=""> &nbsp;&nbsp;&nbsp;case SMALL(30, 30)<br class=""> &nbsp;&nbsp;&nbsp;case MEDIUM(60, 60)<br class=""> &nbsp;&nbsp;&nbsp;case LARGE(120, 120)<br class=""> &nbsp;&nbsp;&nbsp;var width: Double<br class=""> &nbsp;&nbsp;&nbsp;var height: Double<br class=""> &nbsp;&nbsp;&nbsp;init(width: Double, height: Double) {<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.width = width<br class=""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.height = height<br class=""> &nbsp;&nbsp;&nbsp;}<br class="">}<br class=""><br class="">I'm not sure about 'var' clause in that example as it causes all the confusion.<br class=""><br class="">I can access additional info stored in enum case, but it cannot be<br class="">modified. Format.SMALL doesn't change, as well as non of its<br class="">properties.<br class=""><br class="">// allowed usage<br class="">let format = Format.SMALL<br class="">let width = format.width // this would be equal to 30 (const value<br class="">assigned to 'width' property on enum case .SMALL)<br class=""><br class="">// not allowed usage<br class="">let format = Format.SMALL<br class="">format.width = 40 // error, stored values are immutable and can not be modified<br class=""><br class="">We get all advantages of enumeration type, and, assuming all cases are<br class="">describing the same possible state, we can store some extra<br class="">information in each case. This can be called a third enumeration type<br class="">feature, right next to associated values and rawType.<br class=""><br class="">--<br class="">| Mateusz Malczak<br class=""></div></div></blockquote></div><br class=""><div class="">Can't this problem most easily be solved by a raw value? Like so:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">enum</span><span style="font-variant-ligatures: no-common-ligatures" class=""> Format : </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class=""> {</span></div></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span><span style="font-variant-ligatures: no-common-ligatures" class=""> small = </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">30</span></div></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span><span style="font-variant-ligatures: no-common-ligatures" class=""> medium = </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">60</span></div></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span><span style="font-variant-ligatures: no-common-ligatures" class=""> large = </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">120</span></div></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span><span style="font-variant-ligatures: no-common-ligatures" class=""> width:</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class=""> { </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">rawValue</span><span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span><span style="font-variant-ligatures: no-common-ligatures" class=""> height:</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class=""> { </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">rawValue</span><span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div></div></blockquote><br class=""><div class="">Granted this becomes more complex if you want to specify widths and heights that do not match, as you can't currently specify a tuple as the raw value, but if you could then that seems like it would be a better solution to this problem surely?</div></body></html>