[fpc-devel] Compile time functions

Sven Barth pascaldragon at googlemail.com
Sun Jul 29 09:14:41 CEST 2018


Thorsten Engler <thorsten.engler at gmx.net> schrieb am So., 29. Juli 2018,
04:40:

> type
>
>   TMyClass = class of TMyObject;
>
>   TMyObject = class
>
>     procedure InstanceMethod; //Self = TMyObject, can be virtual
>
>     class procedure ClassMethod; //Self = TMyClass, can be virtual
>
>     class procedure StaticClassMethod; static; //no Self, really just a
> global procedure in a scoped namespace
>
>   end;
>
>
>
> var
>
>   o: TMyObject;
>
>   c: TMyClass;
>
> begin
>
>   o.InstanceMethod; //if virtual, calls resolved based on actual class
>
>   o.ClassMethod; //if virtual calls, resolved based on actual class
>
>   o.StaticCalssMethod; //can’t be virtual, resolved on variable type
>
>
>
>   TMyObject.ClassMethod; //call resolved based on given type
>
>   TMyObject.StaticClassMethod; //call resolved based on given type
>
>
>
>   c.ClassMethod; //if virtual, calls resolved based on actual class
>
>   //haven’t tried if this one works, I assume it does:
>
>   c.StaticClassMethod; //can’t be virtual, resolved on variable type
>
> end;
>
@Gareth: And I mean the StaticClassMethod here.

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20180729/51e23210/attachment.html>


More information about the fpc-devel mailing list