Queue  View Entry  
  Advanced
Main -  My Queue -  My Data Stores  -  New Entry -  Settings -  Downloads -  Logout -  Help!

iframes are OFF to turn them ON click here
Data Store Entry   Location  Created  Actions  
Linus On Coding Style
1 Oct - 7 Oct (26 posts) Subject: "[patch] Workqueue Abstraction, 2.5.40-H7"

In the course of discussing a workqueue abstraction patch, Linus Torvalds gave
some opinions of coding style issues:

  Pease don't introduce more typedefs. They only hide what the hell the thing
  is, which is actively _bad_ for structures, since passing a structure by
  value etc is something that should never be done, for example.
 
  The few saved characters of typing do not actually _buy_ you anything else,
  and only obscures what the thing is.
 
  Also, it's against the Linux coding standard, which does not like adding
  magic single-letter suffixes to things - that also is the case for your
  strange "_s" suffix for a structure (the real suffix is "_struct").
 
  Remember: typing out something is not bad. It's _especially_ not bad if the
  typing makes it more clear what the thing is.
 
He added in reply to himself:

  Btw, just to avoid counter-examples: Linux does use structures and typedefs
  occasionally to hide and force compiler typechecking on small structures on
  purpose. We have a few places where we do things like
 
          typedef struct {
                  unsigned int value;
          } atomic_t;
  
  (and similar things for the page table entries etc).
 
  This is done because the things are often really regular scalars, but we
  use the structure as a strict type checking mechanism. In this case, using
  a typedef is fine, because we don't actually ever want to _access_ it as a
  structure, and the typedef provices exactly the kind of information hiding
  that we need.
 
  But type hiding for a real structure just doesn't make sense, since we use
  it as a true structure, and hiding information just makes it harder to see.
 
Elsewhere, he added:

  Big things should have big names. That's why "u8" is u8, because it's not
  just physically small, it also has very little semantics associated with
  it.
 
  I want those variable declarations to stand out, and make people understand
  that this is not just a variable, it's a structure, and it may be taking up
  a noticeable amount of space on the stack, for example.
 
  That's the main issue for me. I don't personally care so much about trying
  to avoid dependencies in the header files that can also be problematic.
  That's probably partly because I use fast enough machines that parsing them
  a few extra times doesn't much bother me, and circular requirements tend to
  be rare enough not to bother me unduly.
 
  So the thing is a big red warning sign that you're now using a complex data
  structure, and you should be aware of the semantics that go with it.
software quality   10/14/2002 2:33 PM  
jcohen  
New Window  
Move/Edit  


Main -  My Queue -  My Data Stores  -  New Entry -  Settings -  Downloads -  Logout -  Help!

©2008 IronDust, LLC - admin@irondust.com - IronDust, LLC Home