GPC accepts the following program, but produces quite silly results:
program Foo;
var a: array [1 .. 2] of Integer value (0, 0); i: Integer;
begin i := 1; for a[i] := 1 to 10 do begin WriteLn (i, ' ', a[i]); if a[i] = 5 then i := 2 end end.
The problem is that it evaluates the index i each time, not once before the loop. It would be possible to fix it, but do we really want that? Neither BP nor CP/EP allow it, they allow only identifiers in for-loops.
Waldek and I see no need for such a feature. (If it made it possible to nest a compile-time-unknown number of `for' loops, I could see some point, but of course, it doesn't.)
So, would anybody mind dropping this misfeature, and requiring an identifier in for-loop counters?
The same (and probably a lot of other weird stuff) can be achieved with "extended" `absolute' variables, such as:
program Foo;
var a: array [1 .. 2] of Integer value (0, 0); i: Integer; {$local W-} c: Integer absolute a[i]; {$endlocal}
begin i := 1; for c := 1 to 10 do begin WriteLn (i, ' ', c); if a[i] = 5 then i := 2 end end.
We support `absolute' for BP compatibility, but IMHO then we should restrict it to what BP requires, i.e. really absolute addresses, or the address of entire variables or parameters.
I suppose (hope) few users actually knew about the extended (mis)features GPC allowed, so I hope we can drop them. (If not, we probably should change semantics to evaluate the address once, and not on each usage, as is done now, so if you rely on this behaviour, you might have to change your code anyway -- if nothing else helps, you can always achieve the same effect with type-casting of pointers.) BP compatible code will not be affected.
Any objections?
Frank