From owner-freebsd-current Mon Oct 21 08:22:23 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id IAA18148 for current-outgoing; Mon, 21 Oct 1996 08:22:23 -0700 (PDT) Received: from zwei.siemens.at (zwei.siemens.at [193.81.246.12]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id IAA18139 for ; Mon, 21 Oct 1996 08:22:12 -0700 (PDT) Received: from sol1.gud.siemens.co.at (root@[10.1.143.100]) by zwei.siemens.at (8.7.5/8.7.3) with SMTP id RAA26467 for ; Mon, 21 Oct 1996 17:20:18 +0200 (MET DST) Received: from ws2301.gud.siemens.co.at by sol1.gud.siemens.co.at with smtp (Smail3.1.28.1 #7 for ) id m0vFMAO-00021FC; Mon, 21 Oct 96 17:21 MET DST Received: by ws2301.gud.siemens.co.at (1.37.109.16/1.37) id AA119551258; Mon, 21 Oct 1996 17:20:58 +0200 From: "Hr.Ladavac" Message-Id: <199610211520.AA119551258@ws2301.gud.siemens.co.at> Subject: Re: To: wollman@lcs.mit.edu (Garrett Wollman) Date: Mon, 21 Oct 1996 17:20:58 +0200 (MESZ) Cc: jdp@polstra.com, michaelh@cet.co.jp, current@freebsd.org In-Reply-To: <9610211437.AA10256@halloran-eldar.lcs.mit.edu> from "Garrett Wollman" at Oct 21, 96 10:37:39 am X-Mailer: ELM [version 2.4 PL24 ME8a] Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk E-mail message from Garrett Wollman contained: > > < said: > > > 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. > > Actually, no. typedefs are the ultimate in un-opaqueness. In the C > programming language, I can utter `struct foo' without knowing how > such a structure is defined. I cannot utter `blurfl_t' without it > having previously be defined somewhere. Furthermore, it is not > permissible to twice utter `typedef struct bar bar_t' in a C program. > > The absolute worst-structured program I know (ISI RSVPD) was written > in the `spaghetti typedef' style, and as a result all of its header > files are so entangled with each other that every source file in the > program must include all of them, even in the absence of any > declarations relevant to that source file. I was able to dramatically > clean this up in the version I was working on by simply eliminating > all the typedefs and referring to the structures by their proper tags > (after inventing tags for them) as bwk and dmr intended. You have a point, as long as the 'struct foo' remains a struct ... and then someone changes that into a 'union foo' ... Moreover, uttering 'typedef struct foo foo_t' in a public header file once should be enough (the header file of the component implementing the methods over foo_t.) IIRC, X11 people had no problems with that. Some discipline in physical layout of your implementation is needed (the downside of foo_t approach)--otherwise you get code that includes the whole world millions of times (which does some bad things to the compilation time). The fact that you cannot use typedef as a forward reference should be regarded as a C language defficiency. BTW, this is not intended as a flame-fest fuel. /Marino