> On Jun 10, 2019, at 4:07 PM, Sven Barth via fpc-devel
> <[email protected]> wrote:
>
> Of course the dereferentiation of PBase while always have the size of TBase.
> That's the point of a pointer. You need to add a static Create method to each
> subclass if you want to use that concept. And no kind of TClassSelf or
> whatever will help you there as you'd need virtual class functions for that
> and objects don't support those just as they don't support a "class of" kind
> of type. There's a reason why classes are superior in nearly all cases after
> all.
>
Got it. That aside the operators are the important thing anyways.
Another question. I’m not sure it’s possible but I did try to add management
operators to objects and found that if a initialize operator was declared in a
unit which was precompiled and then inherited from an object in another unit
which declared another initialize operators, the initialize operator would be
called twice.
The issue is that the operator is compiled into some other code which always
gets called when the object is used as a var type. Is there any work around to
that? The options I’m aware of are:
1) don’t allow management operators in objects (that would be very unfortunate
indeed).
2) don’t allow subclasses to redeclare a management operator (that seems ok
since the operator can call a virtual method from the base class).
3) allow overriding of operators. I don’t think that would be make sense or
perhaps even possible.
Regards,
Ryan Joseph
_______________________________________________
fpc-devel maillist - [email protected]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel