glob2-devel
[Top][All Lists]
Advanced

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

Re: [glob2-devel] Coding conventions


From: Andrew Sayers
Subject: Re: [glob2-devel] Coding conventions
Date: Wed, 13 Jul 2005 03:53:05 +0100
User-agent: Mutt/1.5.9i

I sort of realised I was picking a bit of a fight with some of these,
and coding conventions are more personal than a lot of things in
programming, so I understand if the answer to some of this stuff is a
flat "no".

> > * typedefs and enums that specify a high-level logical idea are written
> >   like "toto_friendliness_t".  This is the way C does it, and adding the
> >   "_t" on the end makes emacs realise it's a type.
> 
> I do not agree. Typedef are aliases for class and should follow class naming 
> conventions. Enums are constants and should follow constant and define 
> conventions (ALL_CAPITALS_WITH_UNDERSCORE).

You make a good point that typedefs for classes should follow class
naming conventions, but what about typedefs for basic types?  For
example, "toto_friendliness_t" could be a bool.  If there's no existing
precedent about typedefs for basic types, could me make the rule that
typedefs should follow the naming convention of the thing they are an
alias for (typedefs for classes resemble classes, typedefs for ints
resemble ints, etc.)?

As for enums - are you referring to the values in an enum or the name of
the enum itself?  In other words, is it OK to do:

enum toto_friendliness_t { ARCH_NEMESIS REGULAR_NEMESIS FRIEND BEST_FRIEND };

Incidentally, on the subject of #defines, are #defines with arguments
used anywhere in the code?  If not, can we mark them as undesirable?
They can be better implemented by inline functions, and can have
unexpected results anyway.

> > * constants are named like variables, except they have "_c" appended to
> >   them if they're shadowed by a function name.
> 
> I disagree, same remarks as 2 step higher.

<thinks>

Er, yeah.  I suppose that is better.  Although I use constants quite a
lot (I don't like putting bald numbers into code), so that might make
what I do look kinda shouty.

        - Andrew




reply via email to

[Prev in Thread] Current Thread [Next in Thread]