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

Dimitri Smits smitco at telenet.be
Tue Oct 19 02:07:25 CEST 2010


----- "Bernd Kreuss" <prof7bit at googlemail.com> schreef:

> On 18.10.2010 15:19, Lukasz Sokol wrote:
> 
> > Having variables declared within code block used to require to parse
> the source code
> > at least 2 times
> 
> Or create them on the stack at the begin and remove them at the end
> of
> the block (which would be the only way to have some additional
> functionality through this).
> 

or do the same as with that vb-ism: the 'with' keyword. Only difference(s): it is named/typed and it is block-scoped from the point of declaration to the end of the current block statement.
(I never use it, so I'm only guessing that it does something similar to the scenario explained above)

on the other hand, what stops the OP from using 'with'? (multiple levels/variables?)

and you won't die from using another stack variable scoped at the beginning of the method.

just to say that I'm not too fond of that c-ism in a pascal language (although I've used it plenty in c++, java, C#, php, ... over the years).

kind regards,
Dimitri Smits



More information about the fpc-pascal mailing list