Question: why ModuleCopy requires _self added to reference local object variables but not any other method?

WHen using _self in object, help says

"As of Maple 2021, if the method has a formal parameter named _self, references
to its object's local or exported variables may be written without prefixing them.
That is, _self:-variable may be written as just variable. Maple will
add the self:- prefix internally when the method is simplified."

And the above is true for all static methods inside an object module, except for ModuleCopy which is also static.

It seems ModuleCopy is special. But why?  I am thinking it is because at time this is called, the object itself does not yet exist, but for all other methods, the object by then is fully constructed. But wanted to be sure.

Here is an example

restart;

person := module()
option object;
local  m_name::string;
local  m_age::integer;
export ModuleCopy :: static := proc(_self :: person
                                   , proto :: person, name::string, age::integer,$
                                )
         m_age := age;
         m_name := name;
    end proc;

export name::static:= proc(_self, $);
    RETURN(m_name); #no need to write _self:-m_name;
    end proc;

export age::static:= proc(_self, $);
    RETURN(m_age); #no need to write _self:-m_age;
    end proc;

export set_name::static:= proc(_self, name, $);
    m_name := name;   #no need to write _self:-m_name := name
    NULL;
    end proc;

export process::static:=proc(_self,$)
   print("name is ",m_name," age is ",m_age);
end proc;

end module:

And now


o:=Object(person,"me",10);

Error, static procedure `ModuleCopy` refers to non-static local or export `m_age::integer` in surrounding scope

Changing ModuleCopy to

export ModuleCopy :: static := proc(_self :: person
                                   , proto :: person, name::string, age::integer,$
                                )
         _self:-m_age := age;
         _self:-m_name := name;
    end proc;

Now there is no error. But notice that in all other static methods, I can write  m_name directly without using _self:-m_name;

I looked at help page for ModuleCopy but see no mention of this.

Why ModuleCopy is different?

Maple 2023.2 on windows 10

Please Wait...