On 28/06/2019 00:09, Ben Grasset wrote:
On Thu, Jun 27, 2019 at 4:12 PM Martin <f...@mfriebe.de
<mailto:f...@mfriebe.de>> wrote:
Are indexes to properties intentionally allowed to take "var param"?
Btw it even compiles with an "out" param.
"Var" and "Out" seem bad, although I've always though that "Constref"
*should* be allowed.
Most property index are simple types. So you would not need it.
But *** hypothetically speaking *** constref (and const too) could be
given in the getter, but not in the property
TFoo = class
private
function GetFoo(constref AIndex: Integer): Integer;
public
property Foo[AIndex: Integer]: Integer read GetFoo;
end;
The compiler woull simply (nothing is ever simple ;) ) need to know that
the signature is still valid, even with the constref.
Of course the compiler accepts any data type as valid for the index. So
you could declare a big record for the index, and argue for constref. I
don't really think it is needed.
Another one, that arises suspicion for its validity: open arrays. They
can only be declared in parameter lists for procedures and functions.
Oh and in properties:
TFoo = class
private
function GetFoo(AIndex: array of Integer): Integer;
public
property Foo[AIndex: array of Integer]: Integer read GetFoo;
end;
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel