<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 Feb 20, 2017, at 3:43 AM, Ross O'Brien 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 style="font-family: Helvetica; font-size: 12px; 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;" class="">As Goffredo Marocchi said, I don't want to return to Objective C's dozen import statements at the top of a file, but how would we denote that a file is a member of a submodule? At the moment I think there are four ways - have I missed any?</div><div style="font-family: Helvetica; font-size: 12px; 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;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; 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;" class="">1) Submodules correspond directly to file directories (simple, but possibly binds a project too closely to an operating system, inflexible for systems like Git).<br class=""></div><div style="font-family: Helvetica; font-size: 12px; 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;" class="">2) The submodule has an access control file which lists its member files (as modules do)</div><div style="font-family: Helvetica; font-size: 12px; 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;" class="">3) Files opt-in to membership of a submodule (e.g. 'memberOf Submodule' just below 'import Foundation')</div><div style="font-family: Helvetica; font-size: 12px; 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;" class="">4) Files 'friend' other files into their submodule, somehow.</div></div></blockquote></div><br class=""><div class="">For #4, my suggestion has been to add a single keyword ‘hidden’. &nbsp;Marking something hidden means that things outside of the file can’t see it.&nbsp;</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>public&nbsp;struct MyStruct {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>var a:Int //This is ‘internal'&nbsp;</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>hidden var b:Int //This is also ‘internal’, but is hidden, so is not visible outside the file</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div class=""><br class=""></div><div class="">To let a file see the hidden items, you ‘import hidden’ instead of just ‘import’:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>import hidden MyStruct &nbsp;//Now ‘b' is visible within this file</div><div class=""><br class=""></div><div class="">Because it is still internal, b is still only accessible within the module (even with ‘import hidden’). &nbsp;If it was a ‘public hidden var’ or ‘open hidden var’ then it could be accessed via ‘import hidden’ outside the module as well.</div><div class=""><br class=""></div><div class="">Make sense?</div><div class=""><br class=""></div><div class="">I think this is the simplest way to get behavior similar to protected, friends, and submodules… all with swift’s file-based access approach.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Jon</div></body></html>