At 11:22 PM +0100 15/7/03, Prof A Olowofoyeku (The African Chief) wrote:
What you are describing is almost equal to the "new" style Delphi Classes (actually, this is already over 7 years old, so it is not so new - but I use "new" here to distinguish it from the original BP object model). That type of Delphi compatibility, is, I believe, on the to-do list - but perhaps not a high priority.
Could you describe the differences between Delphi "Classes" and GPC objects?
As I see it, the differences between Mac objects and GPC objects are:
1. methods are always virtual 2. objects are created/destroyed with New/Dispose 3. objects are implicitly pointers 4. fields are implicitly dereferenced 5. there are no (user) contructors/destructors
Frank has implemented an option for 1. I think currently in GPC New( objectpointer ) already handles 2. 5 is not an issue. And so that remains is just 3 & 4 which are related to treating objects as implicit pointers. 4 is the big one since it relates to code scattered all over your program. 3 relates primarily to type handling (essentially declare an implicit pointer when definiing an object type and allow that implicit pointer to be used as the super class for an object (ie mychildobject = object (myparentobject)).
The main difference between what you propose and Delphi is that, under Delphi, you must call the object's constructor before you can do anything with it. The constructor call allocates memory for the object and returns a pointer to it (e.g., "obj := myobject.myconstructor"), and deferencing is automatic. But you must use "Class" when defining the object, and not "Object" (e.g., type myobject = class ....).
Ok, so that at least sounds like the code to implicitly dereference an object pointer will be useful for Delphi classes.
BTW, I'm happy to live with "class" instead of "object" since that can be easily be done with a macro. So if Delphi classes match Mac objects close enough, that's fine. But sooner would be better than later since it is a question of helping make Mac code compatible.
If your suggestion is accepted, then we might one day have 3 kinds of GPC objects - the old BP objects, the Delphi classes, and the Mac Pascal objects. I am not sure where this will lead us. Perhaps the Mac Pascal object type could be implemented as a superset or subset of the Delphi Class (or vice versa), since implementing one will have taken us almost to the point of being able to support the other.
Agreed - at least it seems that a lot of the work is helpful in each case.
So far it doesn't really sound like the objects would be incompatible, as long as GPC objects were explicitly declared as types, then all three should be compatible if we get the handling of constructors just right.
I suspect that none of this is a great priority at the moment - but I might be wrong ....
Getting sufficiently close to source code compatibility for Mac objects would definitely help me (and presumably other Mac users) with the transition.
It'd be great if you could describe the differences between GPC objects and Delphi classes.
Thanks, Peter.