Hello,
On Fri, 19 Apr 2002, Frank Heckenbach wrote:
Maurice Lombardi wrote:
Frank Heckenbach wrote:
Prof Abimbola Olowofoyeku wrote:
On 19 Apr 2002 at 9:10, Adam Naumowicz wrote:
I found out that, unfortunately, the newest GPC has a changed processing of constructors. As far as I know, even the virtual methods should be identified in the compilation time in the sense, that when calling a constructor for an object (for example one with destroyed layout) the methods are called inside the constructor the static way.
That's not really what it did before. What I changed was to remove a (normally) redundant VMT pointer assignment. Usually the VMT pointer is assigned when the variable is created (i.e., at program/routine start for non-pointer objects, and after memory allocation when using `New').
Until recently, GPC *also* assigned the VMT when calling a constructor which is therefore redundant (especially when calling a constructor within `New', one could see two assignments next to each other which made it clear that one was redundant).
So you could have done the other way around, assigning the VMT pointer
only when calling a constructor. This would have given what Adam was expecting. Anyway an object is not valid until a constructor is called. Is there any drawback for that ?
Matter of taste probably ...
I think, that the optimalization of redundant VMTP creation is not very fruitful. In my opinion, the gain it gives is not worth making another step which breaks compatibility with other compilers like Delphi, support for which is one of the nice GPC features. The silly examples I gave you were not just made up, but they came from a piece of code which has worked fine with several compilers for more than 15 years...
What I'm rather thinking of is a "magic" built-in procedure to initialize some given variable the same way it's initialized on creation. Yes, it's magic again (though it would require an explicit call, so it's not magic behind the scenes). And since it would do all the initializations (including discriminants and files, e.g.), it would be more consistent ...
That sounds reasonable, but probably requires much effort involved ;-( Regards, Adam Naumowicz
-------------------------------------- WWW: http://math.uwb.edu.pl/~adamn/ --------------------------------------