Em 11/05/2011 17:01, Vinzent Höfler escreveu:
On Wed, 11 May 2011 12:07:31 +0200, Hans-Peter Diettrich <drdiettri...@aol.com> wrote:

kingbiz...@gmail.com schrieb:

I would like to be able this:
[ some code after begin ]
DoSomething;
var I: Integer;
for I := 0 to 1000 do
DoAnotherThing(I);
[ inside the code ]

That's not good practice, in no programming language.

Better move the loop into a local procedure, where you can declare really local variables.

Or make the loop variable completely implicit and thus 100% local to
the loop.

|for i : integer := 0 to 1000 do ...;


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

I like this idea, but I'm changing my mind,*maybe is better to keep the current way*, its not really needed to declare a variable inside the codes, its nice, I like it but its not really necessary.

But something that has been pointed (by Joerg I belive) is the initialization of variables, what about it? This would be a nice thing and I don't see why not. I prefer to see:

*var
   X: Integer = 0;
   Y: Integer = 100;*

than

*var
  X: Integer;
  Y: Integer;
begin
  X := 0;
  Y := 100;*
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to