<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 11, 2016 at 8:21 PM, Charles Srstka via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><span class="gmail-"><blockquote type="cite">On Oct 11, 2016, at 4:42 PM, Braeden Profile via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br></blockquote><div><blockquote type="cite"><br class="gmail-m_-7477081969086525389Apple-interchange-newline"><div><div style="font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">enum</span><span style="font-variant-ligatures:no-common-ligatures"> RectSize</span></div><div style="font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures">{</span></div><div style="font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures">   </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">let</span><span style="font-variant-ligatures:no-common-ligatures"> height:</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(91,38,153)">Int</span></div><div style="font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures">   </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">let</span><span style="font-variant-ligatures:no-common-ligatures"> width:</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(91,38,153)">Int</span></div><div style="font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures">   </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">case</span><span style="font-variant-ligatures:no-common-ligatures"> small(width: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(218,32,0)">30</span><span style="font-variant-ligatures:no-common-ligatures">, height: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(218,32,0)">30</span><span style="font-variant-ligatures:no-common-ligatures">)</span></div><div style="font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures">   </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">case</span><span style="font-variant-ligatures:no-common-ligatures"> medium(width: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(218,32,0)">60</span><span style="font-variant-ligatures:no-common-ligatures">, height: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(218,32,0)">60</span><span style="font-variant-ligatures:no-common-ligatures">)</span></div><div style="font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures">   </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,143,1)">case</span><span style="font-variant-ligatures:no-common-ligatures"> large(width: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(218,32,0)">120</span><span style="font-variant-ligatures:no-common-ligatures">, height: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(218,32,0)">120</span><span style="font-variant-ligatures:no-common-ligatures">)</span></div><div style="font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px;font-size:11px;line-height:normal;font-family:menlo"><span style="font-variant-ligatures:no-common-ligatures">}</span></div></div></blockquote></div><br></span><div>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><br></div><div>enum RectSize {</div><div><span class="gmail-m_-7477081969086525389Apple-tab-span" style="white-space:pre-wrap">        </span>var height: Int { get }</div><div><span class="gmail-m_-7477081969086525389Apple-tab-span" style="white-space:pre-wrap">        </span>var width: Int { get }</div><div><br></div><div><span class="gmail-m_-7477081969086525389Apple-tab-span" style="white-space:pre-wrap">        </span>case small {</div><div><span class="gmail-m_-7477081969086525389Apple-tab-span" style="white-space:pre-wrap">                </span>height { return 30 }</div><div><span class="gmail-m_-7477081969086525389Apple-tab-span" style="white-space:pre-wrap">                </span>width { return 30 }</div><div><span class="gmail-m_-7477081969086525389Apple-tab-span" style="white-space:pre-wrap">        </span>}</div><div><br></div><div><span class="gmail-m_-7477081969086525389Apple-tab-span" style="white-space:pre-wrap">        </span>case medium {</div><div><span class="gmail-m_-7477081969086525389Apple-tab-span" style="white-space:pre-wrap">                </span>height { return 60 }</div><div><span class="gmail-m_-7477081969086525389Apple-tab-span" style="white-space:pre-wrap">                </span>width { return 60 }</div><div><span class="gmail-m_-7477081969086525389Apple-tab-span" style="white-space:pre-wrap">        </span>}</div><div><br></div><div><span class="gmail-m_-7477081969086525389Apple-tab-span" style="white-space:pre-wrap">        </span>case large {</div><div><span class="gmail-m_-7477081969086525389Apple-tab-span" style="white-space:pre-wrap">                </span>height { return 120 }</div><div><span class="gmail-m_-7477081969086525389Apple-tab-span" style="white-space:pre-wrap">                </span>width { return 120 }</div><div><span class="gmail-m_-7477081969086525389Apple-tab-span" style="white-space:pre-wrap">        </span>}</div><div><br></div><div><span class="gmail-m_-7477081969086525389Apple-tab-span" style="white-space:pre-wrap">        </span>case custom(width: Int, height: Int) {</div><div><span class="gmail-m_-7477081969086525389Apple-tab-span" style="white-space:pre-wrap">                </span>height { return height }</div><div><span class="gmail-m_-7477081969086525389Apple-tab-span" style="white-space:pre-wrap">                </span>width { return width }</div><div><span class="gmail-m_-7477081969086525389Apple-tab-span" style="white-space:pre-wrap">        </span>}</div><div>}</div></div></blockquote><div><br></div><div>I&#39;d be interested in expanding raw values to accommodate other types, but computed properties are already possible:</div><div><br></div><div>```</div><div>enum RectSize {</div><div>    case small, medium, large</div><div><br></div><div>    var height: Int {</div><div>        switch self {</div><div>        case .small:</div><div>            return 30</div><div>        case .medium:</div><div>            return 60</div><div>        case .large:</div><div>            return 120</div><div>        }</div><div>    }</div><div>    </div><div>    var width: Int {</div><div>        return height</div><div>    }</div><div>} </div><div>```</div><div><br></div><div>There have been off-and-on proposals to change the syntax from what it is currently, but none have been deemed a significant enough advantage to merit a change--even before source-breaking changes in Swift 3 were over. Keeping in mind that sugar is the lowest priority for Swift 4 (and not in scope for the current phase), what&#39;s the advantage of your proposed syntax for computed properties over the existing one?<br></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div></div><div>(syntax not exact; this is pseudocode, modify the syntax as appropriate)</div><div><br></div><div>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><br></div><div>Charles</div><div><br></div></div><br>______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote></div><br></div></div>