Am 21.12.2010 00:16, schrieb Jonas Maebe:

On 20 Dec 2010, at 21:37, Sven Barth wrote:

I have taken the time to implement a first version of Delphi's class helpers. 
Thanks to Jonas' code for Objective C categories it was a rather easy to get 
that working.

Note that Delphi-style class helpers have several limitations that still have 
to be added to your patch:
a) from http://docwiki.embarcadero.com/RADStudio/2010/en/Class_and_Record_Helpers : 
"You can define and associate multiple helpers with a single type. However, only 
zero or one helper applies in any specific location in source code. The helper defined in 
the nearest scope will apply. Class or record helper scope is determined in the normal 
Delphi fashion (for example, right to left in the unit's uses clause)." -- In 
Objective-C, there is no limit on the number of categories for a class that applies at 
the same time.

I don't know whether we should really follow this limitation (and when, then only in mode Delphi)

b) afaik, Delphi class helpers cannot contain virtual methods, and definitely 
cannot override methods defined in a parent class (the used VMT is that of the 
helped class, so no additions/changes to the class that require VMT changes are 
allowed or even possible)

- should class helpers be able to be instantiated or even referenced in any 
way? (including forward declarations)

No. They are not first class entities, they just add a bunch of method 
declarations to the scope of the extended class.

- should class helpers be allowed to override/reintroduce methods?

Definitely no override. I don't know about reintroduce.

- 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, that does not make any semantic sense. How they are implemented in the 
compiler is irrelevant.

- should abstract methods be forbidden?

Yes, since
a) they are virtual
b) even if it were possible to have virtual methods, there would be no way to 
override them with implementations that do something (since you cannot inherit 
from a class helper)


I'll take your answers into account.

Regards,
Sven
_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to