<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
Em 11/05/2011 17:01, Vinzent Höfler escreveu:
<blockquote cite="mid:op.vvb1wxzrw5hir6@jellix.jlfencey.com"
type="cite">On Wed, 11 May 2011 12:07:31 +0200, Hans-Peter
Diettrich <a class="moz-txt-link-rfc2396E" href="mailto:DrDiettrich1@aol.com"><DrDiettrich1@aol.com></a> wrote:
<br>
<br>
<blockquote type="cite"><a class="moz-txt-link-abbreviated" href="mailto:kingbizugo@gmail.com">kingbizugo@gmail.com</a> schrieb:
<br>
<br>
<blockquote type="cite">I would like to be able this:
<br>
[ some code after begin ]
<br>
DoSomething;
<br>
var I: Integer;
<br>
for I := 0 to 1000 do
<br>
DoAnotherThing(I);
<br>
[ inside the code ]
<br>
</blockquote>
<br>
That's not good practice, in no programming language.
<br>
<br>
Better move the loop into a local procedure, where you can
declare really local variables.
<br>
</blockquote>
<br>
Or make the loop variable completely implicit and thus 100% local
to
<br>
the loop.
<br>
<br>
|for i : integer := 0 to 1000 do ...;
<br>
<br>
<br>
Vinzent.
<br>
_______________________________________________
<br>
fpc-devel maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.freepascal.org/mailman/listinfo/fpc-devel">http://lists.freepascal.org/mailman/listinfo/fpc-devel</a>
<br>
</blockquote>
<br>
I like this idea, but I'm changing my mind,<b> maybe is better to
keep the current way</b>, its not really needed to declare a
variable inside the codes, its nice, I like it but its not really
necessary.<br>
<br>
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:<br>
<br>
<b>var<br>
X: Integer = 0;<br>
Y: Integer = 100;</b><br>
<br>
than<br>
<br>
<b>var<br>
X: Integer;<br>
Y: Integer;<br>
begin<br>
X := 0;<br>
Y := 100;</b><br>
</body>
</html>