myoo - The new TCL 'oo' extension
myoo is an attempt to rethink the topic of Object-Oriented-Programming (OOP) in TCL, offering a maximum of Object-Oriented-Programming (OOP) functionality with minimal effort.
The aim is to offer an identical API via both C and TCL, taking into account the integration in the meta-code-compiler (META-COMPILER) as well as in the TCL-COMPILER.
Array versa Namespace
I struggled with whether myoo should be array-reference-based or namespace-reference-based.
After doing some research with the tclmyoo TCL-API and libmyoo C-API I switch to namespace-reference-based
The following reasons led to the switch to namespace-reference :
- With TclGetNamespaceFromObj from the tcl internal Int-API, a very powerful tool is available for resolving a namespace.
- It has been confirmed that namespace upvar NS my my is significantly faster than upvar NS::my my.
- To call a sub-method, the local-reference no longer needs to be resolved because the instance-namespace is always used for the global namespace (::).
- An external-pointer can also be attached to the tcl internal Tcl_Namespace* pointer, which speeds up the All-Language-Compiler (ALC) compiler massively.
- The code becomes much smaller and simpler by switching to the namespace-reference, so that I can proudly say that myoo is by far the smallest Object-Oriented-Programming (OOP) in the world.
- Even with the tcl-only version, tclmyoo is faster than tcloo with over ten years of development work.
source code
code example
performance example