<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><blockquote type="cite" class="">On Oct 11, 2016, at 4:42 PM, Braeden Profile via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></blockquote><div><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><div class="" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 143, 1);">enum</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;RectSize</span></div><div class="" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">{</span></div><div class="" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;&nbsp;&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 143, 1);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;height:</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(91, 38, 153);">Int</span></div><div class="" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;&nbsp;&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 143, 1);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;width:</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(91, 38, 153);">Int</span></div><div class="" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;&nbsp;&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 143, 1);">case</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;small(width:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(218, 32, 0);">30</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, height:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(218, 32, 0);">30</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)</span></div><div class="" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;&nbsp;&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 143, 1);">case</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;medium(width:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(218, 32, 0);">60</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, height:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(218, 32, 0);">60</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)</span></div><div class="" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;&nbsp;&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 143, 1);">case</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;large(width:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(218, 32, 0);">120</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, height:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(218, 32, 0);">120</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)</span></div><div class="" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</span></div></div></blockquote></div><br class=""><div class="">I like the concept, but this doesn’t seem as flexible as it could be, and could get ugly when mixing these defaults with enum associated values. How about dynamic properties instead? Something like:</div><div class=""><br class=""></div><div class="">enum RectSize {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>var height: Int { get }</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>var width: Int { get }</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>case small {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>height { return 30 }</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>width { return 30 }</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>case medium {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>height { return 60 }</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>width { return 60 }</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>case large {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>height { return 120 }</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>width { return 120 }</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>case custom(width: Int, height: Int) {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>height { return height }</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>width { return width }</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div class="">}</div><div class=""><br class=""></div><div class="">(syntax not exact; this is pseudocode, modify the syntax as appropriate)</div><div class=""><br class=""></div><div class="">This would keep the property implementations separate from the associated values, and would also allow for the computed properties to do more complex calculations if necessary.</div><div class=""><br class=""></div><div class="">Charles</div><div class=""><br class=""></div></body></html>