Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Oct 1996 19:37:04 -0700
From:      John Polstra <jdp@polstra.com>
To:        Michael Hancock <michaelh@cet.co.jp>
Cc:        current@freebsd.org
Subject:   Re: <sys/queue.h> 
Message-ID:  <199610210237.TAA05813@austin.polstra.com>
In-Reply-To: Your message of "Mon, 21 Oct 1996 10:32:42 %2B0900." <Pine.SV4.3.93.961021100431.20316B-100000@parkplace.cet.co.jp> 

next in thread | previous in thread | raw e-mail | index | archive | help
> > And it
> > is in line with C++ practice, where the struct, class, or union
> > keyword is almost never used outside of the declaration.  (I know,
> > this is C, not C++.  But the idea that the name of a type should
> > not carry unnecessary information about its representation is a
> > valid one.)
> 
> It's questionable to define a typedef just to save typing the word struct.

True, but that's not the point.  The point is, at a certain level,
a type is a type is a type.  You shouldn't have to know whether
it's represented as a struct or as a union or as an array.  By
using a typedef you enforce not knowing the details of the
representation, making it easier to change that representation in
the future without having to change a bunch of code.  The more
opaque a type is, the easier it is to change it later, if you need
to.

It isn't about saving typing, just as "dev_t" isn't about avoiding
typing "unsigned int", and "jmp_buf" isn't about avoiding typing
"struct { int _jb[9]; } foo[1];"  It's about information hiding.

Also, it's important to note that that part of my argument was about the
use of typedefs in general, and not specifically about <sys/queue.h>.

John



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199610210237.TAA05813>