Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!gatech!mcnc!rti!xyzzy!throopw From: throopw@xyzzy.UUCP (Wayne A. Throop) Newsgroups: comp.lang.c Subject: Re: interesting type problem Message-ID: <279@xyzzy.UUCP> Date: Mon, 28-Sep-87 14:19:18 EDT Article-I.D.: xyzzy.279 Posted: Mon Sep 28 14:19:18 1987 Date-Received: Tue, 29-Sep-87 07:08:37 EDT References: <8626@utzoo.UUCP> Organization: Data General, RTP NC. Lines: 36 > henry@utzoo.UUCP (Henry Spencer) > Consider the following problem. [A type 'T' at least partially composed of > a pointer to type 'T'] [...] > It can't be done in strictly portable C using "efficient" pointers True. The problem is that C has no way to introduce a type by name before or during the definition of that type, except with struct, union, or enum. Thus, there is no way to specify a recursive type, except inside structures, unions, or enumerations. I personally think that "typedef" ought to do this, so that one could say things like typedef foo_t *foo_t; to declare foo_t as a pointer type, pointing to foo_t. Of course, this complicates the parse of such things beyond belief (or it seems to... I haven't really tried hard to come up with a simple scheme because it looks so hopeless). Perhaps a new keyword, such as "forward", which could introduce a recursive typedef, so that something like: typedef forward foo_t; typedef foo_t *foo_t; would work just fine, because foo_t can now be recognized as both a type and the name being defined. Though maybe even this doesn't solve it. Sigh. -- Inigo hated it there. Everybody was so dangerous, big, mean and muscular, and so what if he was the greatest fencer in the world, who'd know it to look at him? He looked like a skinny Spanish guy it might be fun to rob. You couldn't walk around with a sign saying "Be careful, this is the greatest fencer since the death of the Wizard of Corsica. Do not burgle." --- From The Princess Bride by William Goldman -- Wayne Throop !mcnc!rti!xyzzy!throopw