<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On 29 Jun 2016, at 22:41, David Sweeris via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Speaking of C++, is the “group” keyword even necessary? To borrow your own example from earlier, it seems like we could just as easily say this:<div class=""><div style="margin: 0px; line-height: normal;" class=""><div style="font-family: Menlo; color: rgb(187, 44, 162); margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">public</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">struct</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> A {</span></div><div style="font-family: Menlo; color: rgb(187, 44, 162); margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">public</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> { </span><span style="color: rgb(0, 132, 0);" class="">// all public</span></div><div style="font-family: Menlo; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> member1() {}</span></div><div style="font-family: Menlo; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> member2() {}</span></div><div style="font-family: Menlo; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> member3() {}</span></div><div style="font-family: Menlo; margin: 0px; line-height: normal;" class=""><span style="color: rgb(187, 44, 162);" class=""> </span>}</div><div style="font-family: Menlo; margin: 0px; line-height: normal;" class=""><span style="color: rgb(187, 44, 162); font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="color: rgb(187, 44, 162); font-variant-ligatures: no-common-ligatures;" class="">public</span><span style="color: rgb(187, 44, 162); font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">labelName</span> {<span style="color: rgb(0, 132, 0);" class="">// all public, accessible under `foo.lableName`</span></div><div style="font-family: Menlo; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> member4() {}</span></div><div style="font-family: Menlo; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> member5() {}</span></div><div style="font-family: Menlo; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">func</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> member6() {}</span></div><div style="font-family: Menlo; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> }</span></div><div style="font-family: Menlo; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">}</span></div><div class="">(which is not C++’s syntax, I know… the comment just got me thinking about it is all)</div><div class=""><br class=""></div><div class="">- Dave Sweeris</div></div></div></div></div></blockquote><br class=""></div><div>This form is interesting, but personally when it comes to grouping I've become a huge fan of using focused extensions, meaning my type declarations are usually nothing but the bare minimum definition for stored properties and required constructors, everything else goes into the most relevant extension.</div><div><br class=""></div><div>As such it seems to me like this feature request could be handled by two features; named extensions, and access modifiers on extensions, so I could do something like so:</div><div><br class=""></div><div><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>public struct A { … }</font></div><div><font face="Monaco" class=""><br class=""></font></div><div><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>// My awesome labelName implementation</font></div><div><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>public extension A.labelName {</font></div><div></div><div></div><div><span class="Apple-tab-span" style="font-family: Monaco; white-space: pre;">                </span><span style="font-family: Monaco;" class="">func member4() { … }</span></div><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space: pre;">                </span>func member5() { … }</font><div><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space: pre;">                </span>func member6() { … }</font></div><div><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</font></div><div><br class=""></div><div>Here the public modifier changes the default for functions without a modifier of their own, purely for convenience (as they can still be overridden if I need a private method to implement them) and the label lets me organise them under the parent type. Multiple such extensions could be specified for the same label, with their own default access and/or type constraints.</div><div><br class=""></div><div>So yeah, grouping is handy, but I think that extensions already provide a good way to achieve this, and it would make more sense to focus any additions onto them.</div></body></html>