[fpc-pascal] class property accessor static

Sven Barth pascaldragon at googlemail.com
Tue Feb 7 19:23:52 CET 2017


Am 07.02.2017 14:31 schrieb "Graeme Geldenhuys" <
mailinglists at geldenhuys.co.uk>:
> I never understood Object Pascal's class methods/properties either?
> Unlike Java, not everything needs to be in a class. We are allowed to
> have procedures or functions, and global ones at that. So in Object
> Pascal we could simply have a unit called FooStuff where everything
> related to Foo is defined, then have a global function F() and then use
> it as follows...

It allows for grouping. This way one can directly see (by using the
completion window or by peeking at the declaration oneself) that there is a
routine F() that belongs somehow to TFoo. If you put that into a separate
unit however then it isn't clear by itself that the stuff relates to TFoo.
In the end it's a question of taste. I personally like class methods and
class properties.
Oh and don't forget that non-static class methods can be virtual (sometimes
I really miss that in C++).

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170207/b16e673c/attachment.html>


More information about the fpc-pascal mailing list