On 9 Aug 2005 at 19:18, Frank Heckenbach wrote:
Prof A Olowofoyeku (The African Chief) wrote:
The other question is if Root is in fact a proper ancestor of TObject (not by definition, of course, but perhaps by their features). Have you, or someone else, checked this?
AFAIK, in Delphi, TObject has no ancestor, either by definition or feature. It is an abstract object that is simply "TObject = Class". But then it also becomes the implicit ancestor of anything defined as "Class". Perhaps there is something circular or recursive going on here?
This would be what I meant by definition. By their features, I mean that someone would have to compare the features of TObject in Delphi and Root in OOE and verify whether the latter are a proper (and compatible) subset of the latter. Perhaps Waldek or someone else has done that already, but I don't know ATM. If that's not the case, I think this idea will fail.
I can't see any incompatibility. The OOE docs says this:
"6.6.2 Root. The predefined identifier Root represents an abstract class that is the parent of all user-defined concrete and abstract classes. The Root class has as its interface the methods that are specified in the following subsections. The Root class is defined as follows:
TYPE Root = ABSTRACT CLASS CONSTRUCTOR Create; DESTRUCTOR Destroy; FUNCTION Clone : Root; FUNCTION Equal (R : Root) : Boolean; END; NOTE: An implementation can add other things to the class Root."
This looks pretty compatible with TObject to me. TObject has a Constructor called "Create" and a destructor called "Destroy". It doesn't have "Clone" or "Equal".
The OOE docs say this about the constructor and destructor:
"6.6.2.1 Create. Create is a constructor with no parameters. Its action is to create an object of the class in which it is used. When overridden, the programmer can specify additional actions to be taken after creation.
6.6.2.2 Destroy. Destroy is a destructor with no parameters. Its action is to destroy the object. When overridden, the programmer can specify additional actions to be taken before the object is destroyed."
Nothing in these is incompatible with TObject (indeed, they seem to have precisely the same function).
As for "Clone", I have no idea what the OOE docs mean when they say this:
"6.6.2.3 Clone. Clone is a functional method without parameters. It returns the result of the predefined function Copy. NOTE: The recommended method of redefining Clone is to specify inherited Clone as the first operation in the overriding method. This way, the clone is built in a top-down fashion."
This is the blurb about "Equal":
"6.6.2.4 Equal. Equal is a functional method that compares two reference values. It has one parameter: a reference to an object. If not overridden, its action is to return True if the parameter is a reference to the same object as Self; otherwise, it returns False."
Therefore, since Root only has these four methods, and no fields, it seems that it can quite properly be an ancestor of TObject.
PS: I don't think there is any need to hide TObject in OOE mode, as long as it is not the implicit ancestor object in that mode.
I think the "need" is just the same as for hiding Root in Delphi mode (as long as it's not the implicit ancestor). Both may not be strictly required, but would be in accordance to our policy of only allowing the dialect's features in a dialect mode.
TObject has much more than Root. If I were to use the OOE object model, I might still want to take advantage of the added functionality of TObject (and this is not in anyway incompatible with OOE). OTOH, the concept of an ancestor for TObject in the Delphi model can lead to potential incompatibilities, hence the need to hide Root in that model.
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.greatchief.plus.com/