Coding style issue
- From: Owen Taylor <owt1 cornell edu>
- To: gtk-list redhat com
- Subject: Coding style issue
- Date: Tue, 02 Dec 1997 10:52:20 -0500
In gtk-rlb-971111-0.patch.README, Rob Browning wrote:
> I don't know if it's a violation of the Gtk coding standard, but I
> moved some variables inside the "if's" local scope so they wouldn't
> take up stack space when not needed (assuming that the optimizer
> doesn't kill them anyway in that situation), and so that you can't
> accidentally refer to them when you didn't mean to. If that's not OK,
> please let me know so I don't do it in the future.
The original GTK style certainly didn't do that. But I don't
think it's a bad thing. In fact, the GNU coding standard says:
"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."
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?)
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]