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? I know there’s 
not overloading of property names but at least the parameters could be 
overloadable so the correct property is chosen depending on what the args are.

type
  TMyClass = class
    function GetValueWithInt(index: integer): TValue;
    function GetValueWithString(index: string): TValue;
    property IndexI[index: integer]: TValue read GetValueWithInt; default;
    property IndexS[index: string]: TValue read GetValueWithString; default;
  end;

 
o := c[index]; // IndexI wins
o := c[‘key’]; // IndexS wins

Regards,
        Ryan Joseph

_______________________________________________
fpc-devel maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to