Path: utzoo!mnetor!uunet!steinmetz!ge-dab!codas!pdn!alan From: alan@pdn.UUCP (Alan Lovejoy) Newsgroups: comp.lang.modula2 Subject: Re: union types Message-ID: <2641@pdn.UUCP> Date: 28 Mar 88 15:06:22 GMT References: <8803221947.AA00248@nrl-iws6.ARPA> <8803242203.AA28027@ndsuvax.UUCP> Reply-To: alan@pdn.UUCP (0000-Alan Lovejoy) Organization: Paradyne Corporation, Largo, Florida Lines: 37 In article <8803242203.AA28027@ndsuvax.UUCP> Info-Modula2 Distribution List writes: >Mark, I believe the closest you could come to simulating the C union >statement would be using a Variant record. I know this involves an >extra identifier, but I don't know any way around this. I am currently >trying to write a program that translates C procedures to Modula2 >procedures and that is how I chose to translate the C union type. Why does a variant record require an extra identifier? The only extra identifier I know of is OPTIONAL: TYPE TaggedVariant = RECORD CASE type: CARDINAL OF 0: foo: Foo; | 1: bar: Bar; END; END; UntaggedVariant = RECORD CASE CARDINAL OF 0: foo: Foo; | 1: bar: Bar; END; END; Variant records do not have to have a tag field. What other extra identifier could there be? Did you mean the identifier that specifies the type of the case labels (CARDINAL in the examples above)? If so, that identifier is a compile-time creature only--it has no existence at run time. --alan@pdn