[fpc-pascal] Can variables be declared within a block?

Jürgen Hestermann juergen.hestermann at gmx.de
Tue Oct 19 07:23:38 CEST 2010


Reimar Grabowski schrieb:
> for (int i = 0;...)
> Can't see anything wrong. I use declaration of variables inside blocks quite often in Java and C++ 
> but have never missed it in pascal. Please enlighten me. What is so bad about creating temporary variables 
> inside blocks instead of the beginning of a function in a language that supports it?

I never thought about doing such declarations in Pascal.
Although I would not be against it in general (provided
that all identifiers have to be different) I see one
(small) disadvantage:

If you want to know the number of bytes pushed to the stack
(i.e. in a recursive function) then you don't have the declarations
at one place anymore but they are spread over the code which 
would make it hard to get an overview.



More information about the fpc-pascal mailing list