2017-02-07 12:10 GMT+01:00 Mattias Gaertner <nc-gaert...@netcologne.de>:
> The getter/setter of a class-property must be "static" (Delphi > compatible). > If I understand "static" correctly, then "static" simply omits passing > the class as parameter. So a static class procedure is just a dumber > version of a normal class procedure. > > What is the advantage of using "static" for class property accessors? > Aka: Why did Delphi choose static here? > Generally "static" means no hidden parameter "self". "static" for methods is used for methods designed for callbacks from external API. We have 3 possibilities: ===code begin=== type TFooClass = class of TFoo; TFoo = class function A: Int32; // self as instance class function B: Int32; // self as meta class of TFoo class function C: Int32; static; // no self property D: Int32 read A; property E: Int32 read B; class property F: Int32 read C; ===code end=== "class property" has two advantages. First: you can use "static" methods for properties and second: will work for improper implemented code ;) (which is maybe disadvantage?): TFoo($1).F; TFooClass($1).F; -- Best regards, Maciej Izak
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal