<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="">Nevin had a fantastic proposal for submodules which changed private to mean “private to the submodule”, where each file was implicitly a submodule unless you declared otherwise. Simple and elegant.<div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 23, 2017, at 6:27 PM, Drew Crawford 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 dir="auto" class=""><div class=""><br class=""></div><div class=""><div class=""><br class=""><br class="">Sent from my iPhone</div>On Mar 23, 2017, at 6:41 PM, David Hart <<a href="mailto:david@hartbit.com" class="">david@hartbit.com</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class="">I have difficulties imagining a submodule proposal that could allow us to eliminate fileprivate. Care to give an example?</div></blockquote><br class=""><div class="">The obvious example would be Rust. Rust has exactly two visibilities, and merely one keyword. By default, members are "private" which is visible inside the module (so, like Swift's internal). The "public" keyword is similar to Swift. </div><div class=""><br class=""></div><div class="">The reason this works is that unlike in Swift where a module is something like a library or framework (Rust calls those "crates"), in Rust modules in are (explicitly) lexically scoped; a "mod myscope {}" module can be created for the portion of the file for which the member should be visible and it won't be visible outside that scope. Likewise, "fileprivate" can be achieved by enclosing the file in a "mod MyFile {}". And like all lexical scopes, they can be recursively nested to arbitrary depth to achieve any number of visibility behaviors (e.g., declare a module for the first half of two files) that would require complex new keywords to achieve in Swift. <span style="background-color: rgba(255, 255, 255, 0);" class="">Finally there are some shortcut features like the ability to infer a module structure from the file system. </span></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">In Swift, modules are presently tied to libraries/frameworks in a 1:1 way. Because of this we lack the flexibility of recursively nestable modules of other languages and this is the underlying problem that motivates both scoped/private and fileprivate. If we fixed that, we would actually not need either keyword. </div><div class=""><br class=""></div><div class=""><a href="http://rustbyexample.com/mod/visibility.html" class="">http://rustbyexample.com/mod/visibility.html</a></div><div class=""><a href="https://doc.rust-lang.org/book/crates-and-modules.html" class="">https://doc.rust-lang.org/book/crates-and-modules.html</a></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>