Re: [gtk-list] Coding style issue



Owen Taylor <owt1@cornell.edu> writes:

> "Instead of doing this, it is better declare a separate local
>  variable for each distinct purpose, and give it a name which is
>  meaningful.  This not only makes programs easier to understand, it also
>  facilitates optimization by good compilers.  You can also move the
>  declaration of each local variable into the smallest scope that includes
>  all its uses.  This makes the program even cleaner."

IMO, they forgot to add "it's safer too".  It makes it harder to
shadow values, or accidentally use them before you meant to (common in
copy-paste errors).

> I've done this in before places in GTK where I thought it was better -
> other people have too. If nobody objects, I would suggest we declare
> this OK. I'm sure there are arguments the other way too, though.
> (Peter?)

OK (give em an inch...), then what about const?  I've wanted to use it
where appropropriate too.  It makes things safer, and it too can be a
help to the compiler wrt to optimizations.

Thanks

-- 
Rob Browning <rlb@cs.utexas.edu>
PGP fingerprint = E8 0E 0D 04 F5 21 A0 94  53 2B 97 F5 D6 4E 39 30



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]