byte-motion / byte-motion/RNL_RAPIDLibrary
In-RAPID "True" Object emulation with overwritable method inheritance, and data inheritance
- Dominant language
- AMPL
- Stars
- 0
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
## "True" object emulation is possible with the following features:
### Features:
- All object methods can be 100% called by late binding (method name, arguments, everything)
- Objects can inherit methods and data from other objects (Inheritance can be decided per object instance basis, which is interesting)
- Inheritable methods are overwritable (If the same method is declared in a parent object and child object, then the child version will be called, allows for great flexibility)
- Objects are declared and stored by user (No arbitrary limits on pre allocated data) (Some exceptions may exist with non-value and semi value variables )
- Does not limit "Normal" programming (but might be slightly more complex to work with than other implementations of "object")
- Due to the 100% late-bindable nature, the use can add new objects without changing ANYTHING in the built in code.
- Adding methods or data to already declared objects is surprisingly simple, hopefully allowing the user to expand on object and build their own.
### The drawbacks
- Impossible to use Functions as object methods -> solution: use procedures with a argument for output
- Optional arguments are not late-bindable, and therefore does not work with inheritance.
- All object data must be global (Might be fixable with more complex pointers)
- All data used as arguments must be global (Might be fixable with more complex pointers)
- All method argument data types is alias with a single, generic, pointer type.
- All arguments to object methods MUST be converted to generic pointer type. (including nums, string, bools...), can be done with a simple inline function call (like offs() or reltool() ).
- Setting up an object, and the constructor of the object, can be complicated
### Implementation is possible due to:
- late binding of procedure calls -> %"Procedure_Name"%
- late binding of data (allows generalized procedure arguments) through a generic pointer (basically ANYTYPE#) -> %"Procedure_Name"% DataPointer1, DataPointer2,DataPointer3, DataPointer4
- Generic code for handling inheritance logic for 100% late bound procedure calls
### The benefits of a "True" object emulation with overwritable inheritance is:
- More flexible and reusable code -> basic features does not need to be implemented in every object, but can be implemented once in a base object that is inherited from.
- Easier expansion
## Comparison to alternative approach: Virtual objects
The previously worked on approach of "Virtual objects" implemented objects in a much looser fashion, and did not late bind data, not implement inheritance of any kind. as a result it is slightly more intuitive, but more work to set up, and less flexible.
### Cons compared to "True" objects
- Lack of overwritable inheritance (or any inheritance) means that a lot of code/features needs to be implemented multiple times, once for each object that needs the feature. (A LOT of more coding and testing required)
- Lack of late binding data (with generic pointer) limits code flexibility, requiring more custom code for each object
### Pros compared to "True" Objects
- More intuitive/easy to use since you don't need to convert data to generic pointers. less complex. methods are called in the normal way which is familiar, but also constricting when it comes to flexibility.
## Conclusion
While "True" Object emulation with overridable inheritance offers some significant benefits over a simpler implementation of "Object - like" structures in RAPID, it also introduces multiple degrees of complexity that can be somewhat but not completely hidden from the user.
For a power user it is a definite upgrade, and it is not impossible to learn for a intermediate programmer. For beginner programmers it might be a hurdle, but most of the complexity should be able to be hidden.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.