On Sun, 14 Feb 2021, Ryan Joseph via fpc-pascal wrote:
On Feb 14, 2021, at 5:30 AM, Michael Van Canneyt via fpc-pascal
<fpc-pascal@lists.freepascal.org> wrote:
Interfaces means an extra object per interface, so more objects on the heap
with all the extra memory management that implies.
You mean COM interfaces? I've only ever used CORBA style ones which I thought
were just contracts basically. The supports() function returns a pointer to
something which I thought was part of the existing VMT table.
That is why I think that a 'trait' using an object/advanced record has it's
advantage: There is only 1 continuous memory block for a class implementing
traits.
Considering the functionality we actually want, i.e. something like inheritance, you could achieve
the trait by simply making an "imports" property. No need to even introduce the extra
"trait" type. For example:
property Test: TTestImpl import FTest;
which is basically the same as:
property Test: TTestImpl read fTest implements ITest; default;
except it doesn't require an interface. The thing we seem to want here is a
default property which works on records/objects so maybe we can just focus on
that? The interface has so much boiler plate and I don't really see what we're
getting in return.
I didn't propose using an interface; For me the
property Test: TTestImpl read fTest implements TTestIimpl;
Where TTestImpl is an object (tp style) or advanced record (delphi style) is
ample.
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal