C99: Suggestions for style(9)

deeptech71 at gmail.com deeptech71 at gmail.com
Sat May 2 02:32:44 UTC 2009


M. Warner Losh wrote:
> Hunting for declarations sucks

I'd rather hunt a bit for its declaration and find uses of it on the 
way, rather than find the declaration..and then what?

> This is a religious point, and we're dangerously close to saying my
> religion is better than your religion.  I don't like this part of the
> proposal at all.  I can see the value in relaxing it for when you have
> a series of variables that are initialized, but relaxing it to the
> point where you intermix code and declarations goes way too far.  It
> is bad enough to have to deal with inner scopes, but tolerable.  It is
> intolerable to have to look for it anywhere in a big function.  It
> tends to encourage spaghetti code, which is one of the things that
> style(9) tries to discourage in many subtle ways.

If there is a function so big that it overwhelms you at first look, do 
not make micro changes to parts unless you know what you are doing, that 
is, you basically looked through the function. I think the thinking 
required for a linear skim is decreased with localized code. And instead 
of making large functions, isn't it recommended to divide it into 
subfunctions, which self-documents the code?

So you should be able to see the declaration "just" above the use. But 
let's consider large functions. If, and after looking at the top of the 
function, you can't see the declatation there either, the only thing you 
have to do is run a search down the function, and the declaration is 
found [epsilon time wasted?].


More information about the freebsd-hackers mailing list