c99/c++ localised variable definition

Garance A Drosihn drosih at rpi.edu
Fri Jan 28 10:49:26 PST 2005


At 5:33 PM +0000 1/28/05, Paul Richards wrote:
>
>People used to programming in C++ or Perl (and many others) are
>used to defining variables as near to use as possible. This has
>never been possible before in C, but now with c99 it is.

Well, you could get a similar effect by creating a new scope.

>Personally, I find the c++/perl convention to be much less error
>prone and more intuitive and since c99 now supports it too it seems
>the standards body sees the benefits of this approach as well.
>
>So, are we going to start allowing this feature to be used in
>FreeBSD since it would require a pretty major change to style(9).

I used to do it that way (by creating new scopes and defining
variables in there).  The present style(9) caused me to abandon
that practice, and in hindsight I think my routines are probably
better off with all the variable-declarations grouped together.

I don't feel too strongly about it, but I would slightly prefer
that style(9) stay as it is on this.

-- 
Garance Alistair Drosehn            =   gad at gilead.netel.rpi.edu
Senior Systems Programmer           or  gad at freebsd.org
Rensselaer Polytechnic Institute    or  drosih at rpi.edu


More information about the freebsd-arch mailing list