Coding practices proposals

Tom Yu tlyu at MIT.EDU
Fri Mar 18 11:49:55 EDT 2011


Sam Hartman <hartmans at MIT.EDU> writes:

> Hmm.  I'd like to propose dropping the recommendation against inner
> scope variables and the requirement to clean up owner pointers in the
> top-most scope in this case.

I prefer to retain the recommendation of avoiding inner scope
variables.  Functions complicated enough to need inner scope variables
are often complicated enough that they should be split into smaller
pieces.  There are some borderline examples that I might consider to
be OK, such as local variables inside a small loop body, but they
should still be dealt with carefully.

We should try to determine if modern versions of gdb still have issues
with tracking the values of variables in inner scopes.

> I think a lot of my bias here is from c++, where I've seen a lot of
> advantages to declaration near use.
> I understand that there are significant cleanup advantages to c++ that
> don't apply here.

I forsee situations in C where developers would be strongly tempted to
have multiple cleanup labels in one function to deal with freeing
memory whose pointers are stored in inner scope variables.  I would
like to remove that temptation.



More information about the krbdev mailing list