Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!amdcad!sun!pitstop!sundc!seismo!uunet!mcvax!unido!nixpbe!ugun21!josef From: josef@ugun21.UUCP Newsgroups: comp.lang.modula2 Subject: Re: What is the use of tag fields and c Message-ID: <16900003@ugun21> Date: 26 Jan 89 10:18:00 GMT References: <724@htsa.uucp> Lines: 52 Nf-ID: #R:htsa.uucp:-72400:ugun21:16900003:000:1686 Nf-From: ugun21.UUCP!josef Jan 26 11:18:00 1989 fransvo@htsa.UUCP (Frans van Otten) writes >"What is the use of tag fields and case labels" Well, in Your example, they are of no other use than to identify the different variants of this record. But one could add an identifier to the CASE, e.g. TYPE Example = RECORD CASE tag : CARDINAL OF 1 .. 10 : a : INTEGER; b : BOOLEAN | 11 .. 15 : u : CHAR; v : ARRAY[1 .. 10] OF CHAR ELSE z : CHAR END END; Then You use "tag" as a field of the record AND a selector for the variants. A "useful" example is: TYPE CoordType = (cartesian, cylinder, polar); TYPE Point = RECORD CASE CoordSystem: CoordType OF cartesian: x, y: INTEGER | cylinder: elevation INTEGER; radius: CARDINAL; angle: REAL | polar: radius: CARDINAL; azimuth, elevation: REAL END END; Now You can store information about the kind of coordinate system You are using as well as the coordinates applicable. IMHO The usage of the "variant record" (as it is called in PASCAL) WITHOUT the named tag field is more or less a mis-use. How will You ever find out which variant to use when You haven't stored any hints (If You have stored any, You can use them as tag fields!) Josef Moellers paper mail: e-mail: c/o Nixdorf Computer AG USA: uunet!linus!nixbur!mollers.pad Abt. EG-3 !USA: mcvax!unido!nixpbe!mollers.pad Unterer Frankfurter Weg D-4790 Paderborn tel.: (+49) 5251 104691 Standard disclaimer: Blablabla opinion blablabla employer blablabla!