Question: How to call parent class constructor from sub class in Maple?

I am still struggling understanding Maple Object  inheritance due to lack of good examples and sparse documenation.

This is what I am trying to do. I have base class Person, and then make Employee class which extends Person class and adds new field.   

The constructor to the Employee class then needs to call the constructor to the Person class (its base class) in order to initialize it. The base class constuctor takes care of initialization the fields in the base class.

I do not know how to do this. Actually it is not clear to me how the proto argument gets into play in all of this. I could not find one example that explains how to use proto with inheritance.

I am trying to implement this python example. I will show the code for the Python, and my Maple translation. The part I do not know how to do, it how to call the constructor for the base class from the sub class.  If I do not do this, then the fields of the base class will remain unitilized.

Python example is from

# parent class 
class Person( object ):     
        # __init__ is known as the constructor          
        def __init__(self, name, idnumber):    
       = name 
                self.idnumber = idnumber 
        def display(self): 
# child class 
class Employee( Person ):            
        def __init__(self, name, idnumber, salary): 
                self.salary = salary 
                # invoking the constructor of the parent class  
                #----->>>>> HOW TO DO THIS IN MAPLE?
                Person.__init__(self, name, idnumber)  
        def show(self):

# creation of an object
# variable or an instance 
a = Employee('Rahul', 886012, 30000000)     
# calling a function of the
# class Person using Employee's
# class instance 

Here is the Maple code

    option object; 
    #I made these exported instead of local for ease of printing from outside while
    #debugging , that is all.. These should otherwise be local

    export idnumber::integer:=0;  
    export name::string:="";  

    export ModuleCopy::static:= proc( _self, proto, name::string, idnumber::integer, $) 
        _self:-idnumber := idnumber;
        _self:-name := name;
    end proc;
end module; 
#---- extend the above class 

    option object(person); 
    export salary::integer:=0;  

    ModuleCopy::static:= proc( _self, proto, name::string, idnumber::integer, salary::integer , $) 
        _self:-salary := salary;
        # invoking the constructor of the parent class  
        # How to do that in Maple?

        #I could always manually do this. But I do not want to duplicate the code
        #done by the base class constructor.
        #_self:-name := name;
        #_self:-idnumber := idnumber;
    end proc;
end module; 


How does one do the Python example in Maple?

Someone should write a book on programming using OOP in Maple. I'll buy a copy in advance.

Maple 2022.1

Please Wait...