5.117 How to call sibling’s proc without making the sibling module exported?

Given a parent module \(A\) and inside it there are two child modules (local modules) with names say \(B\) and \(C\). To call a proc foo inside \(B\) from another proc inside \(C\), the proc foo has to be exported. But the module \(B\) does not have to be exported, if we make sure to use B:-foo() call instead of full name A:-B:-foo() call.

So make sure to use child:-proc() from other siblings to avoid having to make each child exported. Making children exported means they can be seen and called directly from outside the parent which his not what we want.

Here is an example

restart; 
 
A:=module()  #parent 
 
  export main:=proc() 
     C:-foo(); 
  end proc; 
 
  local B:=module()  #child 
     export foo:=proc() 
        print("in A:-B:-foo() proc"); 
     end proc; 
  end module; 
 
  local C:=module() #child 
     export foo:=proc() 
        print("in A:-C:-foo(). About to call A:-B:-foo()"); 
        B:-foo();  #do this and NOT A:-B:-foo() 
     end proc; 
  end module; 
end module;
 

and now

A:-main() 
     "in A:-C:-foo(). About to call A:-B:-foo()" 
     "in A:-B:-foo() proc"
 

If instead we have written  A:-B:-foo() in the above call, then Maple will complain with the error Error, (in foo) module does not export `B`