@nm You wrote:
- So having "export" on ModuleCopy in the child was the problem.
Yes, and it's mostly just a syntactic problem: Anything that's local or export in the parent is considered to be already declared in the child, including keyword procedure names like ModuleCopy.
- Then the child constructor (since it overwrote the base class constuctor method) has now to duplicate all this work. right?
Amazingly, no, it's not overwritten. On help page ?object,create, the 3rd paragraph of the subsection "Inheritance" is this extremely cryptic paragraph:
- Static members will be shared with the base class, or not, depending on the value they have in the base class. Static members whose value is a procedure or module with a ModuleApply function (methods) will be reinstantiated in the derived class. All other static members (i.e. data members) will be shared with the base class.
This is saying that when a procedure (or appliable module) is declared static in the parent and reassigned in the child, it is not overwritten; rather, the child gets its own static procedure distinct from the parent.
- It would be better if Maple OOP allowed child class constructor to call base class constructor directly as in Java and C++ and all other OOP languages.
The child is allowed to invoke the parent's copy of any redefined procedure by using the module-prefix (:-) syntax. According to the 7th paragraph from the same subsection:
- A method in a derived class that replaces an inherited method can invoke the base class' method by calling it explicitly. For example, a method M inherited by class T from class T0 but then reassigned in T, can call the original method using T0:-M().
I believe these 8 paragraphs are the only documentation of inheritance. It's shocking that the Examples section of this help page doesn't have any example of inheritance.