[swift-evolution] [Proposal][Discussion] Modular Swift
alblue at apple.com
Tue Feb 21 06:44:45 CST 2017
> On 21 Feb 2017, at 07:00, Jaden Geller via swift-evolution <swift-evolution at swift.org> wrote:
> We avoid forcing users to organize code in such an opinionated manner just to please the compiler. Perhaps some submodules deserve a separate file, but I think that choice should not be forced by the language. I don’t have data on the popularity, but I personally very much dislike the similar restriction Java places on public classes and files.
On the other hand, having such standardisation means that you know exactly where a type is based on its module membership. One of the outcomes of Scala's move away from enforcing a relationship between files and their module structure means that it is almost impossible to find where a type is defined using the filesystem, and you resort to using 'git grep' or other tools to find out where the implementation is located.
> Given that we want Swift to be a fantastic scripting language, I feel we ought not place artificial restrictions on code organization. Many scripts are a single file (for convenience) but may still benefit from the organization modules offer.
Is there a reason why a script should need to be in any module, as opposed to a top-level/unnamed module?
More information about the swift-evolution