Question: why _self is needed when using overload for object constructor?

I do not know if this is a bug or a feature.

Compare these two

 

The fix is that when using overload, one must explictly add _self. So it becomes _self:-_name:=name  instead of just _name:=name when not using overload. Now it works.

But why?  Is this a bug or there is a reason why one must add _self:- when  using overload?

interface(version);

`Standard Worksheet Interface, Maple 2026.1, Windows 10, April 28 2026 Build ID 2011354`

restart;

module person_type()
    option object;
    local _name::string;
    
    export ModuleCopy::static := overload([
        proc( _self::person_type, proto::person_type,
              name::string,$) option overload;
        _name := name;
       end proc
       ]);
end module:

o := Object(person_type, "me");

Error, static procedure `person_type:-ModuleCopy` refers to non-static local or export `person_type:-_name::string` in surrounding scope

restart;

module person_type()
    option object;
    local _name::string;
        
    export ModuleCopy::static :=proc( _self::person_type,
           proto::person_type, name::string,$)
        _name := name;
       end proc;
end module:

o := Object(person_type, "me");

module person_type () local _name::string; option object; end module

 


 

Download test_overload_in_OOP.mw

Please Wait...