Question: can _self have type :: in the proc signature?

THis is something I always wondered about.  I do not remember if I asked about this before or not. But if I did, I still do not have an answer.

in Maple Object module, I can write _self::  and add the name of the module, only in the constructor proc.

But in other procs inside the object module, it gives error when adding :: to _self.

Is this by design or Am I doing something wrong?

Below is work sheet showing 3 examples of calling proc inside the object. I am using the o:- form of the call, where o here is the object. So the first argument in each proc inside the object must have _self. 

Only when I just write _self without  type :: it works.  

The question is: can one add :: to _self in object proc signatures or must it only be _self with no :: ?

interface(version)

`Standard Worksheet Interface, Maple 2024.2, Windows 10, October 29 2024 Build ID 1872373`

 

Example 1 does not work

 

restart;

A:=module()  
   export module person()
      option object;
      export name::string;
      export ModuleCopy::static := proc( _self::person, proto::person, name::string, $ )
         _self:-name:=name;
      end proc;

      export get_name::static:=proc(_self::person,$)
          _self:-name;
      end proc;
   end module;

end module;

_m1810198326240

o:=Object(A:-person,"me");
o:-get_name();

module person () export name::string; option object; end module

Error, invalid input: person:-get_name uses a 1st argument, _self (of type person), which is missing

 

Example 2 does not work

 

restart;

A:=module()  
   export module person()
      option object;
      export name::string;
      export ModuleCopy::static := proc( _self::person, proto::person, name::string, $ )
         _self:-name:=name;
      end proc;

      export get_name::static:=proc(_self::A:-person,$)
          _self:-name;
      end proc;
   end module;

end module;

_m1810198326240

o:=Object(A:-person,"me");
o:-get_name();

module person () export name::string; option object; end module

Error, invalid input: person:-get_name uses a 1st argument, _self (of type person), which is missing

 

Example 3 works

 

restart;

A:=module()  
   export module person()
      option object;
      export name::string;
      export ModuleCopy::static := proc( _self::person, proto::person, name::string, $ )
         _self:-name:=name;
      end proc;

      export get_name::static:=proc(_self,$)
          _self:-name;
      end proc;
   end module;

end module;

_m1810198326240

o:=Object(A:-person,"me");
o:-get_name();

module person () export name::string; option object; end module

"me"

 

 

Download question_on_self.mw

Please Wait...