Date: Mon, 21 Oct 1996 13:15:22 +0200 From: Poul-Henning Kamp <phk@critter.tfs.com> To: Michael Hancock <michaelh@cet.co.jp> Cc: John Polstra <jdp@polstra.com>, bde@zeta.org.au, current@FreeBSD.org, wollman@lcs.mit.edu Subject: Re: <sys/queue.h> Message-ID: <1351.845896522@critter.tfs.com> In-Reply-To: Your message of "Mon, 21 Oct 1996 20:11:45 %2B0900." <Pine.SV4.3.93.961021200032.24461B-100000@parkplace.cet.co.jp>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <Pine.SV4.3.93.961021200032.24461B-100000@parkplace.cet.co.jp>, Mich ael Hancock writes: I agree 100% with the footnote that if a "simple struct" represent a selfcontained object a typedef is OK too. >On Mon, 21 Oct 1996, Poul-Henning Kamp wrote: > >> >It's questionable to define a typedef just to save typing the word struct. >> >> The reason I do it is not to save 7 chars of typing. >> >> It's because we are talking about a self-contained type that carries >> with it all the operations you can perform on it. > >I think you should do the changes you mention to queue.h and change the >man page example to the following... > >*** foo1 Mon Oct 21 20:06:06 1996 >--- foo2 Mon Oct 21 20:05:33 1996 >*************** >*** 1,10 **** > #include <sys/queue.h> > >! SLIST_HEAD(slisthead, entry) head; > struct slisthead *headp; /* Singly-linked List head. */ > struct entry { > int i; >! SLIST_ENTRY(entry) entries; /* Singly-linked List. */ > } *n1, *n2, *n3, *np; > > >--- 1,10 ---- > #include <sys/queue.h> > >! SLIST_HEAD(slisthead, struct entry) head; > struct slisthead *headp; /* Singly-linked List head. */ > struct entry { > int i; >! SLIST_ENTRY(struct entry) entries; /* Singly-linked List. */ > } *n1, *n2, *n3, *np; > > >The original mixes up tag names and type names, which is a bogus thing to >do. > >Use typedefs for scalars such as dev_t and for complex objects that >combine arrays, pointers, structs, and functions. > >For simple structs, the typedef doesn't gain you much aside from not >having to type "struct". > >Regards, > > >Mike Hancock > > > -- Poul-Henning Kamp | phk@FreeBSD.ORG FreeBSD Core-team. http://www.freebsd.org/~phk | phk@login.dknet.dk Private mailbox. whois: [PHK] | phk@ref.tfs.com TRW Financial Systems, Inc. Future will arrive by its own means, progress not so.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1351.845896522>