On 20.06.2019 19:57, Ryan Joseph wrote:
I just had some plans for a cool JSON class thwarted because apparently []
properties don’t allow overloading of the parameters. Can we allow multiple
default properties as long as their parameters are different?
Properties do allow overloading of the parameters.
You only must not declare the overloaded properties but declare
overloaded getters/setters. The compiler will silently accept them.
https://bugs.freepascal.org/view.php?id=28949
Your example:
program Project1;
{$mode objfpc}
type
TValue = record A: Integer end;
TMyClass = class
function GetValue(index: integer): TValue;
function GetValue(index: string): TValue;
property Index[aindex: integer]: TValue read GetValue; default;
end;
{ TMyClass }
function TMyClass.GetValue(index: integer): TValue;
begin
Result.A := 0;
end;
function TMyClass.GetValue(index: string): TValue;
begin
Result.A := 1;
end;
var
c: TMyClass;
begin
c := TMyClass.Create;
Writeln(c[0].A);
Writeln(c['key'].A);
end.
Best
Ondrej
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel