Question: What is the type of package wide variable? it is not local and not global. How to check?

I was trying to find if the type of module wide variable is considered local or global.

I have an exported variable in module. Maple then said it was local . OK

restart;
foo:=module()
   export n::integer;
   export boo:=proc()::integer;
     return n;
   end proc;       
end module;
                   

n:=foo:-boo():
type(n,`local`);

               # true

But when I did this

restart;
foo:=module()
   export n::integer;
end module;

n:=foo:-n;
type(n,`local`)

         #false

Now Maple says it no longer local.

What is the difference? The module wide variable is exported in both cases. So one can access it directly like in the second example above, or via call to a proc inside the module, which returns it.

Why in one case it is local and in the second case it is not?

Ok, I found the issue. It seems when doing return  n; in the first example above, it created and returned a local n to the proc itself (where n was not declared in the example). (even though maplemint did not complain. Strange).

I have assumed when doing return n Maple will know this is the module wide variable n since that is the closest one around.  i.e. the proc is inside the module. And sits inside the module. So return n should referenced this variable. But it did not, because when I changed the code to this

restart;
foo:=module()
   export n::integer;
   export boo:=proc()::integer;
     return foo:-n;
   end proc;       
end module;

n:=foo:-boo():
type(n,`local`);

     #false

Now it returned false. The same as the second example.

But it also returned false when asking if it is global

n:=foo:-boo():
type(n,`global`);

    #false

So the module wide variable in this example is not local and is not global.

Is there another type to use to check if the variable/symbol returned is a module wide type?

Maple 2020.2

Please Wait...