[fpc-pascal] Interface delegates and the implements property specifier

Sven Barth pascaldragon at googlemail.com
Mon Dec 23 08:02:44 CET 2019


Ryan Joseph via fpc-pascal <fpc-pascal at lists.freepasca023815.html ieb am
Mo., 23. Dez. 2019, 06:01:

>
>
> > On Dec 22, 2019, at 5:26 AM, Sven Barth via fpc-pascal <
> fpc-pascal at lists.freepascal.org> wrote:
> >
> > You don't seem to understand what implementing an interface means in
> Object Pascal. It means that a class can be cast to an interface. It does
> *not* mean that the interface's methods are available from that class.
>
> I guess I'm not seeing the design pattern which they was invented for and
> I've never come across it in my own work. Not against the idea in any way
> however.
>
> My mind went in the same direction as Adriaan's did when I saw
> "implements" I thought that one class could be built from many smaller
> classes but share the same namespace (like in multiple inheritance or
> entity/component designs). If a class implements an interface via a
> delegate then I would expect this to function the same as inheritance, i.e.
> the namespaces are merged and share functions. Doesn't that make sense?
>

It does make sense, but not in the context of interfaces. They are not
there to provide implementations, but to provide a known API to the user.



> Maybe what I mean to say is that there's a need for a delegation syntax
> that functions like multiple inheritance and avoids the traps of deeply
> nested single inheritance hierarchies. Does anyone else agree?
>

What might be more interesting in this context than multiple inheritance is
the concept of aspects (aka aspect oriented programming though you might
also want to look for "mixin"; there's an old thread about that:
https://lists.freepascal.org/fpc-pascal/2009-December/023815.html). If we
could find an agreeable syntax and implementation for that then we'd be
potentially inclined to include that as a new feature as there had been
experiments for that in the past.

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20191223/d8d55872/attachment.html>


More information about the fpc-pascal mailing list