[fpc-pascal] class property accessor static

Maciej Izak hnb.code at gmail.com
Tue Feb 7 13:25:16 CET 2017


2017-02-07 13:11 GMT+01:00 Mattias Gaertner <nc-gaertnma at netcologne.de>:

> 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"?
>

Is not related. AFAIK "class property" exist for complexity of language
(otherwise usage of "static" methods would be impossible for "property"
syntax).


> Sorry, I don't get it.
> Why is using a static method as accessor an advantage?
>

You can use Get/Set pair of static methods in "property" form. Might be
more handy.


> > and second: will work for improper implemented code ;)
> > (which is maybe disadvantage?):
> >
> > TFoo($1).F;
> > TFooClass($1).F;
>
> I don't see why these calls require static instead of normal.
>

In other scenario (for normal "property") this call will raise AV.

btw. "class property" is probably slightly faster ;) because don't pass
"self" parameter.

-- 
Best regards,
Maciej Izak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170207/d7e5011f/attachment.html>


More information about the fpc-pascal mailing list