<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 Mar 6, 2017, at 3:04 AM, Rien <<a href="mailto:Rien@Balancingrock.nl" class="">Rien@Balancingrock.nl</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="" class=""><blockquote type="cite" 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-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><br class="">I’m not dead-set on this approach, but as you say, it solves a *lot* of problems that other approaches introduce. I do recognize the reasonableness of the main argument against, that file location shouldn’t have such a dramatic affect on behavior… *but* the fact is (whether by convention or expediency) we already *do* have filesystem location dependencies on our code projects…<span class="Apple-converted-space"> </span><br class=""><br class="">* One can’t willy-nilly move files around the disk and expect a project to build… if you move it somewhere the compiler doesn’t know to look for it, you’re going to break things<br class="">* One can’t just move a file out of your SCM repo root, or you’ll “lose” the file<br class=""></blockquote><br class="">True, but if other files do not refer to the lost file, you don’t even know for which file to look.<br class="">(imo this is already a weak point in swift, but this approach to submodules would make it -much?- worse)<br class=""><br class="">If you were to include filenames in the “submodule declaration file” at least this omission in swift would be partly covered, and you would not need to move the other files into special places. (You could though)<br class=""><br class=""></blockquote><br class="">But isn’t this exactly the same case if you’re using Swift without an IDE? It’s true that Xcode keeps track of files in your project, and there’s no reason it couldn’t also keep track of files in a submodule (in fact it would… it just might not know they belong in the sub-module without some work from the Xcode dev team).<br class=""><br class="">But as a thought-experiment, here’s how I’m thinking of this problem:<br class=""><br class="">Swift (as a language) has established that a file *is* a unit of code. Not the only one of course, but it is one, as evidenced by access controls (fileprivate, Swift2 private) which bound on the file.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; 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; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; 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; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I disagree with this: Swift is just a set of -more or less- arbitrary rules to allow the development of applications.</span><br style="font-family: Helvetica; font-size: 12px; 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; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; 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; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">The criteria for those rules are chosen by the core team and will fluctuate with time.</span><br style="font-family: Helvetica; font-size: 12px; 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; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; 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; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">As such there is no “Swift way” of doing things. Any such remark is by its nature a personal preference. (not that there is anything wrong with that, its just not an argument)</span><br style="font-family: Helvetica; font-size: 12px; 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; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; 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; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; 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; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">(Besides, a computer only knows files, thus of course a file is a unit of code. That does not mean we should extend “code” to be something outside the files)</span><br style="font-family: Helvetica; font-size: 12px; 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; -webkit-text-stroke-width: 0px;" class=""></div></div></blockquote><div><br class=""></div><div>First, that’s simply not true. In Swift 1, a file was *not* a logical unit of code because file boundaries were meaningless to the way the code in the project behaved. In Swift 2 we got `private` which made it possible for file boundaries to affect code behavior. Swift 3 changed `private` but introduced `fileprivate` for the same purpose.</div><div><br class=""></div><div>Second, yes, Swift is just a language, but as that language evolves, it is an expression of the values & preferences of its development team and more recently, this community. If the file was not *intended* to be a unit of code, we would not have `fileprivate`.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div style="" class=""><blockquote type="cite" 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-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">I (and many others) want to be able to describe another unit of code larger than a file and smaller than a Module to help organize the file-units we have which go together within a Module, but which shouldn’t (for various reasons) describe a complete Module in and of themselves.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; 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; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; 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; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Sure, and I have nothing against that. However I an dead set against extending the scope of the language itself to the organisation of its files. It is traditional to leave the organisation of the files to the configuration of the compiler/linker. And I do not see how it would simplify the language itself by extending the language to cover file organisation.</span><br style="font-family: Helvetica; font-size: 12px; 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; -webkit-text-stroke-width: 0px;" class=""></div></div></blockquote><div><br class=""></div><div>Clearly adding any new feature will not simplify the language. The questions are 1) should we add this feature, and 2) how to add the feature. I *do* take your objections to heart and that’s why I added some alternatives not involving the filesystem to my proposal. These alternatives each have their own problems and complications which we can discuss… maybe they’re not as bad as they seem, maybe they’re worse, and *probably*—because I’m just one person—there are solutions to the problem which I haven’t thought of.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="" class=""><span style="font-family: Helvetica; font-size: 12px; 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; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I will predict that if this approach is taken you should brace for the storm that would want to reverse this feature. It would imo dwarf the private vs fileprivate debate.</span><br style="font-family: Helvetica; font-size: 12px; 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; -webkit-text-stroke-width: 0px;" class=""></div></div></blockquote><div><br class=""></div><div>And no one wants that. That’s why we are having this discussion, no? I’ll be honest, I saw the fileprivate/private discussion on this list, and didn’t voice my opinion then because I thought “oh, they’ll do the right thing”, then was unhappy with what we got. That’s the reason I’ve started this discussion, and it’s also the reason I *really* value your dissenting input. I want not just *a* solution, but *the right* solution, and I know I don’t know everything that needs knowing to come up with it alone.</div><div><br class=""></div><div>I and many others want a unit between Module & File. Someone else may not want such a thing, but they don’t have to use it, just like they don’t actually have to use Access Control modifiers. Now, you might object, saying *no one* should be able to organize their code this way… Then I’ll disagree with you on that, and we can discuss that position (and again, maybe I’m wrong, but my experience says otherwise). If you accept that wanting that in-between unit is a reasonable thing for us to want (even if you don’t plan to use it), then lets discuss the second question: “How to do it”.</div><div><br class=""></div><div>One of my goals with this is that it should add *zero* additional ceremony should an author choose not to use it, and have no impact on existing code.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="" class=""><span style="font-family: Helvetica; font-size: 12px; 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; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Besides, why create something new? (Yes there are systems out there that do some of this) There are many existing solutions out there that we could adopt and stay completely within the bounds of the language, and give the users something they are likely already familiar with.</span><br style="font-family: Helvetica; font-size: 12px; 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; -webkit-text-stroke-width: 0px;" class=""></div></div></blockquote><div><br class=""></div><div>I’ve laid out some alternatives, and *to me* the filesystem-based model *currently* looks the best (or at least, “least bad”). You disagree, and that’s fine. And as I’ve said more than once, I’m open to suggestions.</div><div><br class=""></div><div>Many existing solutions that I’ve looked at from other languages face complications when overlaid on Swift due to Swift’s extensions, and the exact structural topology we’re working within (the intersection of: Access Control, type declarations, profligate type extensions, lack of headers, etc), means that a solution for the in-between unit we’re calling ‘sub-modules’ (for lack of a definitive name) *might* need to be somewhat unique to Swift. Or might not.</div><div><br class=""></div><div>We also all want to do what is “right” for the Swift language. Many people were calling for a `protected` access control modifier. That it was common in other languages didn't mean it was right for Swift. </div><div><br class=""></div><div>At the end of the day, I don’t know what the right solution is. This “problem” came about due to the meaning of `private` (and then `fileprivate`), and the “simple” approach taken to access control, which caused us to organize code around the file, causing some *very* large files. Some time back, many people proposed solving this problem through additional Access Control modifiers to "fill in the gaps” between `internal` and `fileprivate`. There has been a lot of discussion on that score, and time and again, the consensus seemed to be “This smells like a sub-modules problem, lets solve it there”. Very well, lets. The problem hasn’t gone away (for those of us who have it).</div><br class=""><blockquote type="cite" class=""><div class=""><div style="" class=""><blockquote type="cite" 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-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">For the moment—though we actually propose to call this unit a sub-module—we'll call this new unit a Foo. Let's describe properties of a Foo:<br class=""><br class="">* A Foo should serve to organize one or more File code units by:<br class=""> - ensuring a File (the code-unit) may belong to one and only one Foo<br class=""> - making clear (with or without an IDE) to which Foo a given file might belong<br class="">* A Foo should have a unique name<br class="">* A Foo should be able to nest under another Foo, and the name of that nesting should be clear & unique<br class="">* A Foo should be able to be easily created, split, and merged as the codebase evolves<br class="">* A Foo should be able to be moved, copied, and SCMed as a unit, without reference to anything outside the Foo<br class=""><br class="">Having now described the critical properties of this new unit called “Foo” have we not also described a filesystem directory?<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; 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; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; 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; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Many things in life share characteristics. And while we should certainly look to them for lessons, we should not conclude that they are the same.</span><br style="font-family: Helvetica; font-size: 12px; 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; -webkit-text-stroke-width: 0px;" class=""></div></div></blockquote></div><br class=""><div class="">And that’s also fair. As I said, it was a thought-experiment trying to explain how I got to the directories concept. If it’s wrong, then it’s wrong. </div><div class=""><br class=""></div><div class="">—Karim</div><div class=""><br class=""></div></body></html>