A technique I often apply is to use a jungle in combination with inheritance (see https://starttorun.info/tackling-connect-iq-versions-screen-shapes-and-memory-limitations-the-jungle-way/ ) to be able to support multiple technologies, yet keep my code readable and managable . The extra classes add a bit of overhead due to the extra objects being used.
It would be good to have the monkey C optimizer be smart enough to detect this pattern and let the optimizer combine the classes into the upper class in the optimization pass.
Constraints:
- the optimizer should handle function overrrides and function inheritance
- the optimizer should only do this optimization if there's no direct use of 1 of the base classes
example:
class A {
function base_method1 () {
System.println("A.base_method1");
}
function base_method2 () {
System.println("A.base_method2");
}
}
class B extends A {
function base_method1 () { // inherit base functionality
A.base_method1();
System.println("B.base_method1");
}
function base_method2 () { // override base functionality
System.println("B.base_method2");
}
}
The result of the optimizer pass should be:
// class A no longer exists
class B { // class B no longer extends
function base_method1 () {
System.println("A.base_method1");
System.println("B.base_method1");
}
function base_method2 () {
System.println("B.base_method2");
}
}