Dear Timur Tabi, In message <ed82fe3e0904081325s560fb99cg83b6aaa9176cd...@mail.gmail.com> you wrote: > > I don't see what's wrong with that. The advantage is that the > variable is close to where it's being used, so that you can see the > context more easily.
Bear with an old man like me. I am used to the habit that variables get decleared at the begin of a block, not in the middle of it. When searching for the declaration of a variable, I find it a major PITA if I have to scan the whole source file instea dof just looking at the first few lines of a block. > I don't see what the value is of limiting the lifetime of the > variable. The compiler isn't going to use that as a hint, anyway. Not the compiler, but humans like me. I have just a small window of lines I can really focus on, and the smaller a block of code (including the needed variable declarations), the easier I get the impression I understand it. > It's just going to use this for syntax checking. If you define and > initialize a variable at the top of the function, but don't use that > variable until a hundred lines later, the compiler is going to > initialize the variable when it's first used, not when the function is > first entered. Chances are it's not even going to define stack space > for it. Keep in mind that we don't write the code for the compiler, but for the human being that comes after us and that has to maintain that code. > > #ifdef CONFIG_COOL_FEATURE > > { > > u32 myvarrocks = foo * bar * bar; > > > > gd->neato = myvarrocks > > } > > #endif > > > > Is this an acceptable compromise? > > This is what we do today, and I think it's ugly. It is ugly, but much less ugly than variable declarations right in the middle of 200 lines of code. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de At the source of every error which is blamed on the computer you will find at least two human errors, including the error of blaming it on the computer. _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot