Question: How to share a submodule among other modules inside a common module without exporting it.

Edit

I found the problem. Let me rephrase it. I keep original question below. 

This causes an error

restart;
interface(warnlevel=4);
kernelopts('assertlevel'=2):
A:=module()
   export module_A1;
   local person_type;

   module person_type()
       option object;
       export name::string; 
       export age::string; 
    end module;

   module_A1:=module()
        export boo;
        boo:=proc()
          local X::A:-person_type;  #THIS LINE CAUSES ERROR
          #local X::person_type;    #THIS LINE ALSO CAUSES ERROR
          #local X;                 #THIS WORKS. No error
          X:=Object(person_type);
          return X;
       end proc;
    end module:
end module:

A:-module_A1:-boo();
           Error, (in boo) module does not export `person_type`

If I change  local X::person_type;  to just local X;  then no error is generated:

restart;
interface(warnlevel=4);
kernelopts('assertlevel'=2):

A:=module()
   export module_A1;
   local person_type;

   module person_type()
       option object;
       export name::string; 
       export age::string; 
    end module;

   module_A1:=module()
        export boo;
        boo:=proc()
          local X;  
          X:=Object(person_type);  #now this works
          return X;
       end proc;
    end module:

end module:

A:-module_A1:-boo();

              `Object<<person_type,1822742359104>>`

So the problem was in the variable declaration. Maple for some reason does not like   local X::A:-person_type;  and does not like local X::person_type; but things seem to work by just removing the ::type altogother. 

So this solves this problem for me for now, I can keep person module local, and still use it in other child modules. Even though I do not understand why Maple complains about it when I use ::

original question. Can be ignored now.

I have one main module, with 2 submodules (child modules) A1 and A2. The child modules are all exported so they can be called from outside the main module.

But I want to have one additional module X as object, to share among the child modules A1 and A2, but without having to also export module X.

But Maple wants me to also export module X in order to use it inside the child modules A1, and A2.

Is there a way to share X  among child modules, without exporting it? I only want X be visible to child modules (i.e. modules inside the main module)

The module X has option object and I want to use it as just a type basically (instead of using Record).

Here is an example

restart;
interface(warnlevel=4);
kernelopts('assertlevel'=2):
A:=module()
   export module_A1,module_A2;
   local person_type;

   module person_type()
       option object;
       export name::string; 
       export age::string; 
    end module;

   module_A1:=module()
        export boo;
        boo:=proc()
          local X::A:-person_type;
          X:=Object(A:-person_type);
          return 1;
       end proc;
    end module:

   module_A2:=module()
        export boo;
        boo:=proc()
          local X::A:-person_type;
          X:=Object(A:-person_type);
          return 1;
       end proc;
    end module:

end module:

Now the call A:-module_A1:-boo(); fail with Error, (in boo) module does not export `person_type`

This can be fixed by changing local person_type;  to export person_type;  but this means person_type can now be seen from outside the main package.

In Ada, it is possible to have private data type shared among child packages. How to do the same in Maple?

 

 

Please Wait...