From: Vadim Lobanov <vlobanov@speakeasy.net>
To: Bill Davidsen <davidsen@tmr.com>
Cc: Coywolf Qi Hunt <coywolf@gmail.com>,
Denis Vlasenko <vda@ilport.com.ua>,
"linux-os (Dick Johnson)" <linux-os@analogic.com>,
Paul Jackson <pj@sgi.com>,
francis_moreau2000@yahoo.fr, linux-kernel@vger.kernel.org
Subject: Re: Use enum to declare errno values
Date: Fri, 2 Dec 2005 08:56:47 -0800 (PST) [thread overview]
Message-ID: <Pine.LNX.4.58.0512020844560.27440@shell4.speakeasy.net> (raw)
In-Reply-To: <4390701C.1030803@tmr.com>
On Fri, 2 Dec 2005, Bill Davidsen wrote:
> Coywolf Qi Hunt wrote:
> >
> > That is a bad bad style. It should be `#define FOO 123' if you have to
> > write it.
> >
> > It's also hard to see what the confusing bar is "if you are looking at
> > file.c alone".
> >
> > enum is worse than typdef. Don't you see why we should use `struct
> > task_struct', rather than `task_t'?
> >
> > Introducing enum alone can't solve the problems from bad macro usage
> > habits. Actually, it's not anything wrong with macros, it's
> > programers' bad coding style.
>
> Using enum doesn't *solve* problems, it does *allow* type checking, and
> *prevent* namespace pollution. Use of typedef allows future changes, if
> you use "struct XXX" you're stuck with it.
You're not stuck with anything onerous in this case. Namely,
If you have "enum XXX" and you want to go to "enum YYY", then...
sed 's/enum XXX/enum YYY/g'
If you have "struct XXX" and you want to go to "struct YYY", then...
sed 's/struct XXX/struct YYY/g'
If you have "enum XXX" and you want to go to "struct YYY", then...
This is a big change, and should be done with care anyway. If struct YYY
happens to be large, then suddenly you can get all sorts of nifty stack
overflows.
In general, code that does not typedef enums and structs unless
absolutely necessary is easier to work with for these reasons:
1) The type of the variable is very obvious from its 'name', without the
uglyness that is Hungarian notation.
2) You don't need to include definition (such as from a header file)
just to declare a pointer to the type. Cuts down on #include clutter.
3) The enum namespace is separate from the struct namespace, which is
separate from other namespaces. Less naming collisions.
YMMV; not an invitation to start a coding style religious war
> --
> bill davidsen <davidsen@tmr.com>
> CTO TMR Associates, Inc
> Doing interesting things with small computers since 1979
> -
-Vadim Lobanov
next prev parent reply other threads:[~2005-12-02 16:56 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-23 13:24 moreau francis
2005-11-23 14:19 ` linux-os (Dick Johnson)
2005-11-23 14:24 ` Denis Vlasenko
2005-11-23 15:00 ` linux-os (Dick Johnson)
2005-11-24 7:19 ` Denis Vlasenko
2005-11-24 7:30 ` Paul Jackson
2005-11-24 7:37 ` Paul Jackson
2005-12-01 20:01 ` linux-os (Dick Johnson)
2005-12-02 6:49 ` Denis Vlasenko
2005-12-02 9:27 ` Coywolf Qi Hunt
2005-12-02 12:07 ` Denis Vlasenko
2005-12-02 12:18 ` Pekka Enberg
2005-12-02 12:56 ` Coywolf Qi Hunt
2005-12-02 13:20 ` Denis Vlasenko
2005-12-02 13:34 ` Pekka Enberg
2005-12-02 16:02 ` Bill Davidsen
2005-12-02 16:32 ` Coywolf Qi Hunt
2005-12-02 16:56 ` Vadim Lobanov [this message]
2005-12-04 13:10 ` Denis Vlasenko
2005-12-02 16:15 ` Bill Davidsen
2005-12-02 17:07 ` Coywolf Qi Hunt
2005-12-02 17:51 ` Steven Rostedt
2005-12-02 18:15 ` Bill Davidsen
2005-12-02 18:30 ` Horst von Brand
2005-11-23 14:27 ` Denis Vlasenko
2005-11-23 14:31 ` Denis Vlasenko
2005-11-23 15:15 ` Alan Cox
2005-11-23 15:44 ` moreau francis
2005-11-23 15:55 ` Nikita Danilov
2005-11-23 16:05 ` moreau francis
2005-11-23 16:24 ` Nikita Danilov
2005-11-23 16:42 ` moreau francis
2005-11-23 16:54 ` Nikita Danilov
2005-11-24 7:22 ` Denis Vlasenko
2005-11-23 17:35 ` Bill Davidsen
2005-11-24 9:43 ` Giuliano Pochini
2005-11-28 23:19 ` Bill Davidsen
2005-11-24 17:11 ` Ben Pfaff
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.58.0512020844560.27440@shell4.speakeasy.net \
--to=vlobanov@speakeasy.net \
--cc=coywolf@gmail.com \
--cc=davidsen@tmr.com \
--cc=francis_moreau2000@yahoo.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-os@analogic.com \
--cc=pj@sgi.com \
--cc=vda@ilport.com.ua \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®