[fpc-devel] Class property and virtual getter

Sven Barth pascaldragon at googlemail.com
Fri Feb 28 07:47:21 CET 2014


On 28.02.2014 02:18, Hans-Peter Diettrich wrote:
> Sven Barth schrieb:
>> Am 27.02.2014 15:35, schrieb Hans-Peter Diettrich:
>>> Also "self" is no more known inside class methods in XE. In D7 it was
>>> the class type instead of the instance pointer. Thus a too
>>> restrictive compiler, geared towards compatibilitiy with *new* Delphi
>>> versions, may break existing code.
>> Source please. This compiles and runs without problems in XE:
>>
>> === source begin ===
>>
>> type
>>   TTest = class
>>     class procedure Test; <---------
>>   end;
>
> When you add "static;", as required for class property getters/setters,
> the following won't compile:

That's why I asked for source. The term "class methods" always implies 
"no static" while those with static are "static class methods".

>
>> class procedure TTest.Test;
>> begin
>>   Writeln(Self.ClassName);
>> end;
>
> So the lack of "Self" seems to apply to "static;" methods, not to
> "class" methods. I'll ask in an EMBT group for a description of
> "static;", the OH seems to reflect the C++ meaning only, without
> mentioning the impact on OPL classes.

A static class method is a method that is basically a normal global 
procedure/function that simply happens to be declared inside a class. 
They are even assignment compatible to normal procvars.

Regards,
Sven



More information about the fpc-devel mailing list