Path: utzoo!attcan!uunet!mcvax!hp4nl!htsa!fransvo From: fransvo@htsa.uucp (Frans van Otten) Newsgroups: comp.lang.modula2 Subject: What is the use of tag fields and case labels in records ? Message-ID: <724@htsa.uucp> Date: 24 Jan 89 19:09:39 GMT Reply-To: fransvo@htsa.UUCP (Frans van Otten) Organization: AHA Technical Institute Amsterdam The Netherlands Lines: 31 In Modula-2, an 'union' is defined like: TYPE Example = RECORD CASE : CARDINAL OF 1 .. 10 : a : INTEGER; b : BOOLEAN | 11 .. 15 : u : CHAR; v : ARRAY[1 .. 10] OF CHAR ELSE z : CHAR END END; Can anyone explain to me what the tag type and the caselabels are used for, apart from informing the reader what the intentions of the programmer might have been ? I know that a tag field can be included, but what is the real difference between an ordinary field and a tag field ? The contents of the tag field are variable and thus unknown at compile time, so the compiler can't check if you're using the correct variant. At run time this is not possible either because the computer can't tell which variant field you are accessing. -- Frans van Otten Algemene Hogeschool Amsterdam Technische en Maritieme Faculteit fransvo@htsa.uucp