On Sat, 13 Oct 2001, Adam Naumowicz wrote:
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's more of an anoyance than a problem. Just omit "const". The following program illustrates there's no side effect: (note: changed "at" to "ax" because "at" is in use.
program foo;
var a:array[0..10] of integer; b,c : integer;
function ax( index:integer):integer; begin ax:=a[index]; index := 5; end;
begin b:=1; c:=ax(b); writeln(b); {writes 1} end.
You can also use c:=a[1];
russ