[fpc-pascal] implements
Graeme Geldenhuys
mailinglists at geldenhuys.co.uk
Wed Sep 6 11:36:18 CEST 2017
On 2017-09-06 09:03, Ryan Joseph wrote:
> For the sake of discussion can you see why it makes sense that “hook.” syntax would be implied because the class does indeed supposedly implement the interface? Everything about the syntax says that the methods in IHook should be in TBaseClass so I can’t help but feel like it was an omission or not fully finished.
"implements" in that example says that the implementation of the IHook
interface is delegated to another class - THook. If you didn't define
the property... implements in TBaseClass, then TBaseClass would have had
to explicitly implement all methods of IHook. The implements means you
can reuse the IHook implementation (thanks to THook) in many other
classes too.
Granted I personally don't like the syntax for "implements", but that's
what Borland came up with for Delphi, and FPC follows that syntax for
compatibility reasons.
The other annoying thing of Object Pascal's Interface support is that
you need to specify which interfaces you implement, even in descendant
classes where the parent already implements a specific interface. But
that's a whole other discussion. ;-)
Regards,
Graeme
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/
My public PGP key: http://tinyurl.com/graeme-pgp
More information about the fpc-pascal
mailing list