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

Lukasz Sokol el.es.cr at gmail.com
Mon Oct 18 15:19:43 CEST 2010


On 18/10/2010 13:58, Frank Church wrote:
> On 18 October 2010 07:49, Florian Klaempfl <florian at freepascal.org> wrote:
[...]
>>>     No.
>>>
>>
> 
> That is a rather emphatic no :).
>  Is there some performance or other related reason why it is a bad idea? I'm
> not knowledgeable in this area but I'd like to know.
> 
> Sometimes my variable declarations is filled with lots of variables for the
> sake of making code involving long derived expressions comprehensible and
> the clutter the understanding at the top level of the procedure.
> 
> Can a procedure be declared inline just for the sake of introducing those
> variables?
> 
> 
I guess it has something to do with 'functions/procedures not to be longer than
3 editor screens' and 'if it is longer and has more responsibilities than 
the name implies, do split it up' kind of paradigm.
c(-like) languages are very bad (don't keep you restrained) at this kind of use ;)
and Gnu Pascal is a mere frontend to GCC so it may inherit c-isms ;)

Having variables declared within code block used to require to parse the source code
at least 2 times as opposed to nice Pascal way of doing it ONCE only. This was a compiler
performance winner in the times of ancient 286, 386 ;)
(dug out from depths of my memory, may be outdated badly).

L.




More information about the fpc-pascal mailing list