Prof. Abimbola A. Olowofoyeku (The African Chief) wrote:
On 22 Oct 2005 at 0:02, Waldek Hebisch wrote:
There is also question if constructors are mandatory for objects with virtual methods.
IMHO they should be - or at least a warning should be generated, except in Mac mode.
Constructors for Delphi and OOE classes will be inherited from base object, so there is no need to check for them. Other classes may work fine without constructors. So the check is debatable.
[...]
-fbase-object= -- to add default parent to object without an explicit parent
I think this should probably be avoided. If someone wants something to be his base object, he should be able to say so when declaring the object.
That was my first thought. But if we require explicit base we will break almost every Delphi program in existence...
With regard to Root and TObject (OOE and Delphi), I have suggested elsewhere that one could probably be a silent ancestor of the other. In fact, they could be one and the same thing (with names changing, and/or members hidden or revealed depending on Delphi or OOE mode). I am not sure whether this makes any sense ...
Consider the following program:
program tsp; type cl = class of TObject; Ob = class(TObject) end; procedure prp1(c : cl); begin while pointer(c) <> nil do begin writeln(c.classname); c := c.classparent; end; end; procedure prp2(c : cl); begin while true do begin writeln(c.classname); if c = TObject then break; c := c.classparent; end; end; begin prp1(ob); prp2(ob); end .
when run using Free Pascal it prints:
Ob TObject Ob TObject
However, if we add extra parent to TObject the first printouts would change. Note that while prp2 would crash on non-Delphi class, both prp1 and prp2 will work fine if we implement Delphi tree correctly.
The other variants also have drawbacks, that is why I would prefer to leave the choice to programmers.