Am 04.06.2020 um 03:45 schrieb Kostas Michalopoulos via fpc-devel:
Hello,
I'd like to add a small feature for property getters to allow
themselves be exposed as a base type of the real field. Example:
===
program ExposeDerivedAsBase;
{$mode objfpc}
type
TBase = class
end;
TDerived = class(TBase)
end;
TSomething = class
private
FProp: TDerived;
public
property Prop: TBase read FProp;
end;
begin
end.
===
The reasoning for this patch is to expose fields directly, without any
additional overheads while being able to hide the real type that the
object uses internally.
I'm against it. It would essentially mean that you can't use the same
field for the setter or that you'd need to go through a method.
Exchanging one restriction (can't use a base class for the property) for
another (can't use the same field for the setter) isn't worth it
especially as you can avoid performance issues by using a getter method
that is declared inline (the only case where this won't help is if you
access it using RTTI, but one call more or less doesn't really change
much anyway).
Regards,
Sven
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel