[fpc-devel] Compile time functions

J. Gareth Moreton gareth at moreton-family.com
Sun Jul 29 15:28:28 CEST 2018


 Thanks everyone! I'm still learning some parts of Pascal!  I'll see if I
can accommodate for that.

 Gareth aka. Kit

 On Sun 29/07/18 08:14 , Sven Barth via fpc-devel
fpc-devel at lists.freepascal.org sent:
 Thorsten Engler  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   _______________________________________________
 fpc-devel maillist - fpc-devel at lists.freepascal.org [2]
 http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
[3]">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

 

Links:
------
[1] mailto:thorsten.engler at gmx.net
[2] mailto:fpc-devel at lists.freepascal.org
[3] http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20180729/47c85852/attachment.html>


More information about the fpc-devel mailing list