Question: Why one needs to give full name on local type declaration vs. proc return type declaration?

In this example, i have a top module A. Inside it, I have module named my_RECORD (which happened to be option object) that I want to return back to caller when they call a proc.

Maple allows me to declare the proc to return my_RECORD. No problem., But when making a local variable inside the proc and using o::my_RECORD it complains  that my_RECORD does not exist. 

The solution is to change o::my_RECORD to o::A:-my_RECORD

My question why it did not complain the same way on the return value on the proc?   for me, they are both semantically the same. One says the proc returns this type, and the other says the local variable is this type. So why had to do A:-my_RECORD on one but not the other? 

Here is an example. Maple 2021.2 on windows 10.

restart;

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

3

A:=module()
 #this is the RECORD to return
  local module my_RECORD()
   option object;
   export data::string:="";
  end module;
   
  export do_analysis:=proc()::my_RECORD;   
    local o::my_RECORD; #error here. But this is the same above line above?    
    o:=Object(my_RECORD);
    o:-data:="test";
    return o;        
  end proc;
end module;

_m2642451182336

A:-do_analysis()

Error, (in do_analysis) type `my_RECORD` does not exist

#FIXED BELOW
restart;

A:=module()
    #this is the RECORD to return
    local module my_RECORD()
        option object;
        export data::string:="";
    end module;
   
    export do_analysis:=proc()::my_RECORD;
          local o::A:-my_RECORD;    
          o:=Object(my_RECORD);
          o:-data:="test";
          return o;        
    end proc;
end module;

_m2642339719872

A:-do_analysis()

module my_RECORD () export data::string; option object; end module

 

Download A_no_lib.mw

Please Wait...