[fpc-pascal] static class methods

Peter Vreman peter at freepascal.org
Thu Feb 7 10:56:10 CET 2008


>
> On 06 Feb 2008, at 23:19, Jonathan Benedicto wrote:
>
>>> From RAD Studio 2007's Help file on Methods
>> (ms-help://borland.bds5/devcommon/methods_xml.html):
>>
>> Like class methods, class static methods can be accessed without an
>> object reference. Unlike ordinary class methods, class static
>> methods have no Self parameter at all. They also cannot access any
>> instance members. (They still have access to class fields, class
>> properties, and class methods.) Also unlike class methods, class
>> static methods cannot be declared virtual.
>> Methods are made class static by appending the word static to their
>> declaration.
>
> In that case the reason that FPC passes a self pointer is probably
> simply because no special support was ever added for static class
> methods (static is parsed for class methods, but I guess nothing is
> done with it afterwards). Feel free to submit a bug report.

Disabling self is not possible. It is required and also used in our RTL:

     class function TObject.InstanceSize : SizeInt;
       begin
          InstanceSize:=pSizeInt(pointer(self)+vmtInstanceSize)^;
       end;


Peter





More information about the fpc-pascal mailing list