Adam Naumowicz wrote:
Hello, I would like to know what is the reason why GPC complains about type mismatch compiling lines like below: ....... var a:array[0..10] of integer;
function at(const index:integer):integer; begin at:=a[index]; end; ....... It seems to me, that there is a too rigid type checking in this matter. Why are constants not allowed here ?
It seems to me that this is a bug. It is said somewhere that a const parameter in a function can be either passed by value or by reference, for optimisation purposes, and this is checked in the programs cstpar1.pas / cstpar2.pas of the test suite. Now both a value parameter or a var parameter is OK, only const complains.
Maurice