Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!yetti!geac!len From: len@geac.UUCP (Leonard Vanek) Newsgroups: comp.lang.c++ Subject: Re: Structures want anonymity, too. Message-ID: <583@geac.UUCP> Date: Mon, 16-Mar-87 13:38:07 EST Article-I.D.: geac.583 Posted: Mon Mar 16 13:38:07 1987 Date-Received: Tue, 17-Mar-87 01:20:57 EST References: <165700008@uiucdcsb> <1062@valid.UUCP> Reply-To: len@geac.UUCP (Leonard Vanek) Organization: Geac Computers Intl. Toronto, CANADA Lines: 45 Summary: Why not provide variant records directly instead? In article <1062@valid.UUCP> roger@valid.UUCP (Roger H. Scott) writes: >We (Valid Logic Systems, Inc.) have modified our 1.1 C++ translator to >allow anonymous structures as well as anonymous unions. Our primary motivation >for this enhancement was for use with our Pascal-to-C++ translator that we >are developing. In Pascal there is a construct known as a "variant record" >that takes the following form (from Jensen & Wirth, 2nd Edition, pp. 42 & 45): > He then goes on to explain the need for the following syntax for emulating a pascal variant record: > >typedef struct { > int a; > union { > struct { > int b, c, d; float e; > }; > struct { > char f[11]; random_type_name g; > }; > }; >} variant_record_example; This is certainly the minimal change to achieve the desired result and may be preferred for precisely that reason. However, it strikes me that if what is wanted is a way to get variant records in C++ (not just for Pascal to C translators but also for original code) why not look for a way to eliminate all of the redundant syntax to come up with a clean ``variant structure'' mechanism? Perhaps it could be modelled on the switch statement in much the same way that Pascal and Ada model their variant records on their case statements? I have not thought this idea out so it may not be all that good, but as long as Bjarne and other readers of this newsgroup are considering the small change maybe you should consider the larger one as well. --------------------------------------------------------------------- Leonard Vanek phone (416) 475-0525 Geac Computers International 350 Steelcase Rd. West Markham Ontario L3R 1B3 Canada UUCP ... {allegra,ihnp4,decvax,pyramid} !utzoo!yetti!geac!len