[fpc-devel] for-in-index loop

Alexander Klenin klenin at gmail.com
Thu Jan 24 23:30:19 CET 2013


On Fri, Jan 25, 2013 at 8:44 AM, Florian Klämpfl <florian at freepascal.org> wrote:
> Am 24.01.2013 22:26, schrieb Alexander Klenin:
>> in all three cases, the effect will be more-or-less the same.
>
> In the first two cases the programmer knows that he does something
> strange, actually he can even adjust i if needed. In the last he might
> expect that i is always correct because it is a language construct and
> he has no change to fix i.

Well, it so happens that the current implementation does what you wish --
i.e. it guarantees that the loop will work regardless of the changes to s.
However, in my opinion that it is an overkill, and careless changing the
iterated object during the iteration *should* lead to exceptions,
since it is a programmer error.
Anyway, this question should be discussed separately from the
for-in-index extension,
since it affects the behaviour of existing code.

--
Alexander S. Klenin



More information about the fpc-devel mailing list