I do not believe I have enough language inside to actually propose a solution. Still I would like to show what I think is the most simplest and flexible way to create modules.
Introduce the ‘module’ keyword to define a module.
To create an empty lexical module named “MyModule”:
To create content for the module define types/functions/variables/protocols etc using the module name with a dot notation:
var MyModule.myVar: Int
Defines a variable at the module level that can be referred to by “myVar” inside the module, and by “MyModule.myVar” outside the module.
Same for functions, classes, protocols etc.
To create a submodule:
To create a sub-sub module:
If no module definition is present, the default module name is the name of the project.
Defining a module with the same name as the project is allowed, but does not create a new module, it simply refers to the default module.
Visibility (access) is created by:
Access level (capability) must be defined by other means (preferably the mechanism proposed by Matthew)