[fpc-pascal] class property accessor static
nc-gaertnma at netcologne.de
Tue Feb 7 13:11:40 CET 2017
On Tue, 7 Feb 2017 12:30:26 +0100
Maciej Izak <hnb.code at gmail.com> wrote:
> 2017-02-07 12:10 GMT+01:00 Mattias Gaertner <nc-gaertnma at netcologne.de>:
> Generally "static" means no hidden parameter "self". "static" for methods
> is used for methods designed for callbacks from external API.
That's an advantage of static methods.
But how is that related to class properties?
How can you use class properties with "methods designed for
callbacks from external API"?
> We have 3 possibilities:
> ===code begin===
> 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
Sorry, I don't get it.
Why is using a static method as accessor an advantage?
> and second: will work for improper implemented code ;)
> (which is maybe disadvantage?):
I don't see why these calls require static instead of normal.
More information about the fpc-pascal