On Tue, 14 Sep 2004 16:52:08 +0200, Paul J Stevens <[EMAIL PROTECTED]> wrote:
> 
> 
> Thomas Mueller wrote:
> > Hi Paul,
> >
> >
> >>I don't get it. Why doesn't freebsd like this code?
> >>
> >
> >>It appears gcc on freebsd doesn't like 'int var=0' type declarations inside
> >>functions. Or am I missing something else here.
> >
> >
> > That's not allowed in C, all declarations have to be first.
> 
> I'll keep that one in mind.
> 
> > C++ allows
> > declarations everywhere. Nevertheless 'declarations first' is a good
> > idea for better readability ...
> 
> Not that I agree with the readability argument though... thinking about some
> very long functions in imapcommands.c with some pretty obscure variables 
> neatly
> declared at the beginning, but unused until a few hundred lines below...
> 
> When I'm in refactoring mode, extracting to new functions, I move all
> declarations to where they are first used, and then move the codeblock to a
> seperate function. I guess doing so a lot lately on the imap code, I got into
> this habit of keeping declarations neatly together with the code that uses 
> them.
> 
> Anyway, hope this fixes it for the freebsd users.

You're correct on the readability part. In very long functions, having
all declarations in the beginning makes things unreadable. Making
functions shorter is the way to fix this :). There are some very long
and ugly functions in some parts of DBMail that need splitting up.

Ilja

Reply via email to