APW 2007-06-06 Some time ago I started efforts to reimplement Itcl on top of tclOO [L1 ]. I started with tclOO using only the API of Itcl; it had about 90% of the test suite of Itcl running successfully, but I saw that after all I was only using a small part of tclOO.
Second approach was implementing a TMOS [L2 ]-like extension using a lot of code of the XOTcl reference implementation but having again about 90% of the test suite of Itcl running successfully. I felt that the code was too big and too complicated, partially because of having all these XOTcl features running. Additionally there were some features of Itcl which would have needed a lot of redesign of that code to pass the Itcl test suite.
So I decided to come back on the tclOO implementation, thinking that is after all the best starting point. This time changing/extending the tclOO code directly to be able to use as much as possible of that code, because I had the feeling it has a lot of good implemented features, which I did like to use. I did also like the implementation of the dispatch and class/object creation mechanism realized there much more then the one in the TMOS implementation.
I started implementing extensions to tclOO (directly in tclOO, as the API is not enough) to get a lot of features of Itcl to run. This includes also a lot of code implemented in pure Tcl above tclOO as far as possible. Doing that I learned a lot more details and "specialities" about Itcl.
Currently I have an implementation which is successfully about 70% of the Itcl test suite.
Having now a better feeling about what is needed for Itcl I will start to write down the missing features and my solution for it in the hope that there will be some comments (especially from dkf). These could also include suggestions on how to solve the problem in a different way, without having to modify tclOO.
In the following solution means: that is my current (not always optimal) solution for the problem.
In the code examples I am using a meta syntax not the Itcl or tclOO syntax to make the code shorter!
Here starts the list; I will add topics if they come up:
class foo { constructor {args} { puts foo } } class bar { constructor {args} { puts bar } } class foobar { superclass foo bar constructor {args} { puts foobar } } class geek { constructor {args} { puts geek } } class mongrel { superclass foobar geek constructor {args} { puts mongrel } } output: geek bar foo foobar mongrel In words Itcl: look in the superclasses starting at the end of the definition, look for inherited classes as long as they exists, if at the root unroll the built stack. go to the next class in inheritance, do the same.
the script after the arguments and before the body is the "constructor init code" class foo { constructor {args} { puts foo } } class bar { constructor {args} { puts bar } } class foobar { superclass foo bar constructor {args} { foo::constructor ; # this is the init code which calls the constructor of class foo } { puts foobar } } class geek { constructor {args} { puts geek } } class mongrel { superclass foobar geek constructor {args} { foobar::constructor } { puts mongrel } } output: foo bar foobar geek mongrel
[ Category Object Orientation | Category discussion | Category Itcl ]