← Back to team overview

kicad-developers team mailing list archive

Re: Position for variable declaration (trivial style issue)

 

On Aug 4, 2013 11:09 AM, "Lorenzo Marcantonio" <l.marcantonio@xxxxxxxxxxxx>
wrote:
>
> During today merge I noticed that some 'new style' variable
> declarations:
>
> function blah()
> {
> int a = 0;
>
> // code
>
> int b = stuff_from_a(a);
>
> // code
> }
>
> were converted to the traditional:
>
> function blah()
> {
> int a = 0;
> int b;
>
> // code
>
> b = stuff_from_a(a);
>
> // code
> }
>
> My preference is to try to restrict the scope of a variable (i.e.
> declare it at the initialization point); the 'old' style could have the
> advantage of seeing from the start all the stuff used. Of course, no
> RAII or collaterals from cons/des, the semantic should be the same (I'd
> say the compiler would optimize both of these in the same way).
>
> Is the traditional style preferred for some reason?

I tend also to prefer the limited scope style.  So if it was some change I
made it was inadvertent, not deliberate.

Getting volunteers to do exact performance is always difficult.




 Just to tune my
> writing style
>
> --
> Lorenzo Marcantonio
> Logos Srl
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp

References