[fpc-devel] RFC: Delphi style class helpers
Paul Ishenin
ip at kmiac.ru
Tue Dec 21 02:48:37 CET 2010
21.12.2010 3:37, Sven Barth wrote:
> Especially at the core devs, but maybe also for other interested persons
> I have the following questions regarding the implementation of this
> feature:
> - should class helpers have access to protected fields of the extended
> class? I propose not or this would beat the complete idea of "sealed" (I
> also believe that Delphi doesn't allow it as well)
Protected, strict protected and private but not strict private.
> - should class helpers be able to be instantiated or even referenced in
> any way? (including forward declarations)
no
> - should class helpers be allowed to override/reintroduce methods?
reintroduce - yes, but since class helper is not a child class using
reitroduce does not do anything.
> - should class helpers be able to extend other class helpers (as class
> helpers are implemented as child classes of the extended class this
> might currently be possible)?
no
> - should class helpers be able to implement interfaces?
This needs to be tested but I don't think they can. You can't define a
helper that implements interface - so all interfaces should be listed in
class. Another thing that you can reintroduce QueryInterface,
GetInterface in the helper but I don't think they will be used by 'is'
and 'as' operators.
> - can/should "message" methods be forbidden?
In delphi they are not forbidden but also they can't be reached by
Dispatch call.
> - should abstract methods be forbidden?
In delphi they are not forbidden and require an implementation. It looks
tht delphi skips 'abstract'. Also delphi skips 'virtual' and 'dynamic'.
I think in FPC this should be forbidden.
> - should a class helper for class X hide a method which was introduced
> in a subclass of X?
no
> - can class helpers extend generic classes?
no one example I tried was able to compile
I have attached few tests which answers to most of your questions.
Best regards,
Paul Ishenin
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: tclasshelper1.dpr
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20101221/df533fd7/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: tclasshelper2.dpr
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20101221/df533fd7/attachment-0001.ksh>
More information about the fpc-devel
mailing list