> On Feb 14, 2021, at 11:14 AM, Sven Barth via fpc-pascal > <fpc-pascal@lists.freepascal.org> wrote: > > It's a runtime conversion, but normally you don't do the conversion for every > method call, but instead cache the interface (or work solely with the > interface), thus the performance impact through the conversion amortizes (and > again, there's so memory allocation by the conversion itself, of course if > the interface getter in case of a interface delegation does a lazy > initialization that's different, but the conversion itself does not require > an allocation).
For default properties no conversion needs to take place even because the compiler can simply find the correct method and return a modified self which points to the struct, like "self.fMyRec" in the example below. In this case the interface doesn't really do anything does it? I think the VMT table is modified and you should probably use CORBA interface unless you want reference counting and extra baggage when you instantiate the class (I assume). If we use records then the memory should be unified (which is good) and with CORBA interfaces no significant baggage during instantiation. Correct me where I'm wrong please. ===================== type TMyRec = record procedure DoX; end; IMyIntf = interface procedure DoX; end; TMyClass = class(TInterfacedObject, IMyIntf) private fMyRec: TMyRec; public property MyRec: TMyRec read fMyRec implements IMyIntf; default; end; Regards, Ryan Joseph _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal