Re: [Oopic-compiler-devel] Testing...
Status: Planning
Brought to you by:
ndurant
From: Neil D. <nd...@us...> - 2004-05-08 08:57:29
|
Backtracking a little... Andrew Porrett wrote: > At 05:15 AM 4/29/2004 +0100, Neil Durant wrote: > >One thing I was thinking about was making the user class idea a little more > >object oriented (taking ideas from C++). [snip] > >And then you would define an object of this type with: > > > > #include "MyClass.h" > > > > MyClass theClass = new MyClass(); [snip] > - is there a significant advantage to this approach, or is it just > something that appeals to a OOP guy? I've just thought of a *huge* advantage to this technique!!! Currently user classes cannot call functions defined within the user class itself, and they cannot refer to the OOPIC object itself (restrictions outlined on page 73 of Dennis' book). However using the ideas I described, we can define a 'this' pointer, which is implicit, and valid within the definition of a user class, and always refers to the object that has been created. 'this' would become a reserved word. If you create two instances of the same user class, the 'this' pointer in each class would refer to the two oUserClass objects. The compiler then knows which object is being referenced within the user class, thus allowing user classes to call their own functions, and to refer to the OOPIC object. They can therefore become true self-contained reusable pieces of code. And we can stop fiddling about with those stupid for loops when we need delays in user classes! This is an idea taken directly from C++/Java/Smalltalk. I don't know why Scott didn't implement it in oUserClass in the first place! Neil -- Neil Durant <nd...@us...> |