Description
I have 3 submodules, called AA, BB, and CC, and an ancestor module KK. I also have 2 vanilla modules XX and YY that hold data (no procedures). I would like to restrict access to XX and YY so they can only be used by descendants of KK. At present the only way to do this is to move the code defining that data from XX and YY so it appears in module KK. This works.
Suppose now that I would like to restrict access to this data within the submodules. Suppose I want AA and BB to have access to the data originally in XX, but disallow CC from such access. This can be achieved, but it requires an additional submodule to be created: let's call it sXX. sXX must be a direct descendant of KK; and AA and BB must be made descendants of sXX. The data that was in XX must appear in sXX. Again, this works.
Suppose now that I realize that AA should NOT have access to the data originally in module YY, but it must remain available to BB and CC. ...AFAICS, there is no way to arrange the tree of the submodules to achieve this. I can, of course, go back to the original setup, where XX and YY are vanilla modules, but this means they would be "public", available to all other code in the program.
What I propose, therefore, is to allow a submodule like sXX to be named on a USE statement in another submodule, providing they both have the same ancestor. AFAIK one cannot specify a submodule name on a USE statement, so relaxing this rule within a submodule set seems appropriate to me. This would allow data to be shared in a flexable way, while keeping it private inside the submodule set.
I guess there would need to be some rule requiring sXX to contain only data... or maybe not? Would it be useful to restrict access to procedures as well? Not sure of this...