[fpc-devel] Declare variables inside the code
kingbizugo at gmail.com
kingbizugo at gmail.com
Thu May 12 04:11:31 CEST 2011
Em 11/05/2011 17:01, Vinzent Höfler escreveu:
> On Wed, 11 May 2011 12:07:31 +0200, Hans-Peter Diettrich
> <DrDiettrich1 at aol.com> wrote:
>
>> kingbizugo at 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 at 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;*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20110511/f97b9d30/attachment.html>
More information about the fpc-devel
mailing list