<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><b>TL;DR</b></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">I’d like to be able to group related internal entities within a namespace declaration, without having to fake it with non-initializable structs:</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="margin: 0px;"><div id="bloop_customfont" style="color: rgb(0, 0, 0); font-size: 13px; font-family: Helvetica, Arial; margin: 0px;"><font face="Courier New">internal namespace AreaOfConcern {</font></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); font-size: 13px; font-family: Helvetica, Arial; margin: 0px;"><span style="font-family: 'Courier New';"> let SomeString = “SomeString”</span></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); font-size: 13px; font-family: Helvetica, Arial; margin: 0px;"><span style="font-family: 'Courier New';"> let SomeInt = 42</span></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); font-size: 13px; font-family: Helvetica, Arial; margin: 0px;"><span style="font-family: 'Courier New';"> func checkSomething() -> Bool {…} </span><span style="font-family: 'Courier New';"> </span></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); font-size: 13px; font-family: Helvetica, Arial; margin: 0px;"><font face="Courier New">}</font></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); font-size: 13px; font-family: Helvetica, Arial; margin: 0px;"><font face="Courier New"><br></font></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); font-size: 13px; font-family: Helvetica, Arial; margin: 0px;"><font face="Courier New"><br></font></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); font-size: 13px; font-family: Helvetica, Arial; margin: 0px;"><b>Rationale</b></div></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">Often within a module I find myself wanting to group related <b>internal</b> entities together within a namespace. Free functions and constants are a good example:</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><font face="Courier New">internal let SomeString = “SomeString”</font></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><font face="Courier New">internal let SomeInt = 42</font></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><font face="Courier New">internal func checkSomething() -> Bool {…} </font></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><font face="Courier New"><br></font></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;">So are thematically-related structs:</div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><font face="Courier New"><br></font></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><span style="font-family: 'Courier New';">internal struct CreateANote: Endpoint {</span></div><div id="bloop_customfont" style="margin: 0px;"><font face="Courier New"> // ...</font></div><div id="bloop_customfont" style="margin: 0px;"><span style="font-family: 'Courier New';">}</span></div><div id="bloop_customfont" style="margin: 0px;"><span style="font-family: 'Courier New';">internal struct UpdateANote: Endpoint {</span></div><div id="bloop_customfont" style="margin: 0px;"><div id="bloop_customfont" style="margin: 0px;"><font face="Courier New"> // ...</font></div></div><div id="bloop_customfont" style="margin: 0px;"><span style="font-family: 'Courier New';">}</span></div><div id="bloop_customfont" style="margin: 0px;"><div id="bloop_customfont" style="margin: 0px;"><span style="font-family: 'Courier New';">internal struct DeleteANote: Endpoint {</span></div><div id="bloop_customfont" style="margin: 0px;"><div id="bloop_customfont" style="margin: 0px;"><font face="Courier New"> // ...</font></div></div><div id="bloop_customfont" style="margin: 0px;"><span style="font-family: 'Courier New';">}</span></div></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">The best way to approximate this currently is to wrap them in a struct, like:</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><font face="Courier New">internal struct AreaOfConcern {</font></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><font face="Courier New"> static let SomeString = “SomeString”</font></div><div id="bloop_customfont" style="margin: 0px;"><span style="font-family: 'Courier New';"> static</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New';">let SomeInt = 42</span></div><div id="bloop_customfont" style="margin: 0px;"><span style="font-family: 'Courier New';"> static</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New';">func checkSomething() -> Bool {…} </span></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><font face="Courier New">}</font></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><font face="Courier New"><br></font></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;">or for thematically-related structs, to enable tidy usage for the callers:</div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><font face="Courier New"><br></font></div><div id="bloop_customfont" style="margin: 0px;"><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><font face="Courier New">internal struct NoteEndpoints {</font></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><span style="font-family: 'Courier New';"> struct Create: Endpoint {</span></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><font face="Courier New"> // ...</font></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><span style="font-family: 'Courier New';"> }</span></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><span style="font-family: 'Courier New';"> struct Update: Endpoint {</span></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><div id="bloop_customfont" style="margin: 0px;"><font face="Courier New"> // ...</font></div></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><span style="font-family: 'Courier New';"> }</span></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><div id="bloop_customfont" style="margin: 0px;"><span style="font-family: 'Courier New';"> struct Delete: Endpoint {</span></div><div id="bloop_customfont" style="margin: 0px;"><div id="bloop_customfont" style="margin: 0px;"><font face="Courier New"> // ...</font></div></div><div id="bloop_customfont" style="margin: 0px;"><span style="font-family: 'Courier New';"> }</span></div></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><font face="Courier New">}</font></div><div id="bloop_customfont" style="color: rgb(0, 0, 0); margin: 0px;"><font face="Courier New"><br></font></div><div id="bloop_customfont" style="margin: 0px;"><font face="Courier New">let endpoint = NoteEndpoints.Create(text: String, …)</font></div></div><div><br></div>This solution is somewhat awkward because <span style="font-family: 'Courier New';">AreaOfConcern</span> and <span style="font-family: 'Courier New';">NoteEndpoints</span> are not really being used as structs so much as an informal namespaces. To communicate this to internal users (and to discourage them from trying to initialize these wrapper structs), you can give them private initializers (which is even more awkward, but helpful):<div><br></div><div><div id="bloop_customfont" style="margin: 0px;"><font face="Courier New">internal struct AreaOfConcern {</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="Courier New"> </font><span style="font-family: 'Courier New';">static</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New';">let SomeString = “SomeString”</span></div><div id="bloop_customfont" style="margin: 0px;"><font face="Courier New"> </font><span style="font-family: 'Courier New';">static</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New';">let SomeInt = 42</span></div><div id="bloop_customfont" style="margin: 0px;"><font face="Courier New"> </font><span style="font-family: 'Courier New';">static</span><span style="font-family: 'Courier New';"> </span><span style="font-family: 'Courier New';">func checkSomething() -> Bool {…} </span></div><div id="bloop_customfont" style="margin: 0px;"><font face="Courier New"><br></font></div><div id="bloop_customfont" style="margin: 0px;"><span style="font-family: 'Courier New';"> private init()</span></div><div id="bloop_customfont" style="margin: 0px;"><font face="Courier New">}</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="Courier New"><br></font></div><div id="bloop_customfont" style="margin: 0px;">It would be preferable if there was another keyword, perhaps <span style="font-family: 'Courier New';">namespace</span>, that could be used as follows:</div><div id="bloop_customfont" style="margin: 0px;"><br></div><div id="bloop_customfont" style="margin: 0px;"><div id="bloop_customfont" style="margin: 0px;"><div id="bloop_customfont" style="margin: 0px;"><font face="Courier New">internal namespace NoteEndpoints {</font></div><div id="bloop_customfont" style="margin: 0px;"><span style="font-family: 'Courier New';"> struct Create: Endpoint {</span></div><div id="bloop_customfont" style="margin: 0px;"><font face="Courier New"> // ...</font></div><div id="bloop_customfont" style="margin: 0px;"><span style="font-family: 'Courier New';"> }</span></div><div id="bloop_customfont" style="margin: 0px;"><span style="font-family: 'Courier New';"> struct Update: Endpoint {</span></div><div id="bloop_customfont" style="margin: 0px;"><div id="bloop_customfont" style="margin: 0px;"><font face="Courier New"> // ...</font></div></div><div id="bloop_customfont" style="margin: 0px;"><span style="font-family: 'Courier New';"> }</span></div><div id="bloop_customfont" style="margin: 0px;"><div id="bloop_customfont" style="margin: 0px;"><span style="font-family: 'Courier New';"> struct Delete: Endpoint {</span></div><div id="bloop_customfont" style="margin: 0px;"><div id="bloop_customfont" style="margin: 0px;"><font face="Courier New"> // ...</font></div></div><div id="bloop_customfont" style="margin: 0px;"><span style="font-family: 'Courier New';"> }</span></div></div><div id="bloop_customfont" style="margin: 0px;"><font face="Courier New">}</font></div><div id="bloop_customfont" style="margin: 0px;"><font face="Courier New"><br></font></div><div id="bloop_customfont" style="margin: 0px;">The namespace keyword would follow all the same scope and dot-notation rules as a structs, but would not be initializable.</div></div></div><div><br><div id="bloop_sign_1455978248620656128" class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">-- <br>Jared Sinclair<br>Sent with Airmail</div></div></div></div></body></html>