Question: how to make TypeTools add private type to my package?

inside my module, I create types to be used by only procs, and other sub modules inside the main one package I have.

but TypeTools:-AddType invoked inside my package, adds the type to system. So a user after loading the package can still see it and use this type.

Adding local before TypeTools:-AddType is not supported.

How to make the type only visible inside the package? Here is example

restart;
kernelopts('assertlevel'=2):
my_pkg:=module()
 option package;
 TypeTools:-AddType(age_type,t->evalb(t::nonnegint and t<150));
 export foo:=proc()
    local age::age_type:=20;
    print("age=",age);
 end proc;
end module;

with(my_pkg);

And now a user can do this

x::age_type:=30;

It worked, since age_type is now in the system. This can also cause a problem, since loading this package, could overwrite a type name allready set there by another package the user happened to load before.

If I can make it at least such that the user has to do 

x::my_pkg:-age_type:=200;

That would be better. But the best solution is to make the type name completely not visible from outside the package. i.e. private type to the package only.

I looked at Extension Mechanisms under typetools in help, but do not see how to use that for what I want.

 

Maple 2020.1

Please Wait...