I would NEVER rely on this in production code. The value of the control
variable of a For loop after execution should never be relied upon. A simple
change in the compiler at some future point could break a lot of your code.

Cheers,

Andy

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Flávio
Etrusco
Sent: 12 March 2007 15:19
To: FPC-Pascal users discussions
Subject: Re: [fpc-pascal] Value of runner variable after a for loop


On 3/12/07, Michael Van Canneyt <[EMAIL PROTECTED]> wrote:
>
> On Mon, 12 Mar 2007, Luiz Americo Pereira Camara wrote:
>
> > Take the following example:
> >
> >  for i:= 0 to 2 do;
> >  WriteLn(i);
> >
> > Can i safely assume that after the for loop the value of "i" is 2?
>
> No. I think it is even specified in the pascal standard.
>

And unless the compiler (programmer) use an extra variable just to
attain this behaviour, the value after the loop will 3 (i.e. end value
+1).

-Flávio
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to