Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site watmath.UUCP Path: utzoo!watmath!kpmartin From: kpmartin@watmath.UUCP (Kevin Martin) Newsgroups: net.lang.c Subject: Re: Shared initial struct elements... history provides an answer? Message-ID: <10977@watmath.UUCP> Date: Thu, 17-Jan-85 21:11:21 EST Article-I.D.: watmath.10977 Posted: Thu Jan 17 21:11:21 1985 Date-Received: Fri, 18-Jan-85 02:21:26 EST References: <10885@watmath.UUCP> <6284@boring.UUCP> Reply-To: kpmartin@watmath.UUCP (Kevin Martin) Organization: U of Waterloo, Ontario Lines: 46 Summary: In article <6284@boring.UUCP> guido@mcvax.UUCP (Guido van Rossum) writes: >(Re: allowing 'partially qualified references' when a structure element >is unnamed and is itself a structure.) > >This proposal doesn't solve any problem. Actually, it does solve a problem. It is just that there is some confusion as to what problem is to be solved. I suspect I am the person who has deviated from the original problem, into one of my own pet peeves. My proposal makes it easier to use complex nestings of structures within unions within structures within..., which improves *one* of the solutions for the several-types-of-structures-with-common-elements problem, namely the solution "declare one structure containing the shared elements, and a union of all the different variations". The only *other* problem with this solution is that the combined structure is at least as big as the largest of its variants. The user can only 'trim' the structure if the compiler actually generates the fields in the declared order (note that this is a necessary but not sufficient condition). >The idea of parially qualified references in itself is nice, though, and >if introduced generally (using the Cobol or PL/1 rules, for instance), >might also be used for shared portions of larger structures as in the >original proposal. I was only thinking of allowing the 'partially qualified references' in cases where the declarator was actually omitted from the original element declaration, e.g., in: struct { union { int x; char *y; float z; } onion; char foo; } var; var.onion.x is legal, but var.x isn't, and in struct { union { int x; char *y; float z; }; char foo; } var; var.x is legal, but var.onion.x (obviously!) isn't. Kevin Martin, UofW Software Development Group