Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Oct 1996 14:13:38 +0100 (BST)
From:      "K.J.Koster" <kjk1@ukc.ac.uk>
To:        hackers@freebsd.org
Subject:   Re: enum considered bad ?
Message-ID:  <Pine.SV4.3.95.961017141154.11417A-100000@kestrel.ukc.ac.uk>
In-Reply-To: <9609178455.AA845559205@cc4.dttus.com>

next in thread | previous in thread | raw e-mail | index | archive | help
> 
> the _size_ of the type, I use #define'd constants and more explicit types.
> 
Hmm. I personally prefer const instead of #define, where possible, because
it gives your constant a type. However, my opinion is colored by c++.
 
Another c-thing that I don't see very often is:

{
   /* ... */
   const size_t len = sizeof (buffer);
   /* ... */
}
 
 instead of
 
{
   size_t len;
 
   /* ... */
   len = sizeof (buffer);
   /* ... */
}
 
This might be useful to track down accidental modifications of len.
Further, it attempts to limit (but fails, it's C ;) the scope of len to
where it's actually used. And it asserts that len is actually initialised
when it's used. It cannot be used uninitialised.
 
Disadvantage is that you don't always know where to look for the
definition of len, it is no longer in the top part of the function. But I
personally find this not a problem, since I try to give varables
meaningful names. (And that is not the "iLen" convention, I _hate_ that)
 
  Groetjes,
    Kees Jan

===========================================================V===
  Kees Jan Koster                              kjk1@ukc.ac.uk
  < no address yet :( >
===============================================================
  Who is this General Failure, and why is he reading my disk?
===========================================================^===




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SV4.3.95.961017141154.11417A-100000>