[fpc-devel] Class property and virtual getter
Ewald
ewald at yellowcouch.org
Mon May 26 14:13:28 CEST 2014
On 05/26/2014 01:04 PM, Michael Schnell wrote:
> On 05/26/2014 12:52 PM, Ewald wrote:
>> A `Class Procedure/Function XXX;` has a hidden parameter that points
>> to the classtype. A `Class Procedure/Function XXX; static;` doesn't
>> have this hidden parameter.
>>
> I see.
>
> The hidden parameter would be accessed as "Self" ?
Probably, I access it through `Classtype` (from TObject), as this gives
me code that will still do the same thing if I remove the `Class` in
front of the procedure/function.
>
> Thanks for the explanation !
>
> Now I came across a "class procedure xyz; virtual;" and was astonished
> that this does compile.
>
> I suppose this means that the hidden parameter will point to the
> classtype of the child instead of the parent in a derived class.
>
It does here (writes DoIt; on stdout):
===
Program Test;
{$mode objfpc}{$H+}
Type
TTestClass = Class
Public
Class Procedure DoIt; virtual;
End;
Class Procedure TTestClass.DoIt;
Begin
WriteLn('DoIt;');
End;
Begin
TTestClass.DoIt;
End.
===
Or am I missing something?
--
Ewald
More information about the fpc-devel
mailing list