Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!aplcen!haven!uvaarpa!vger.nsu.edu!g_harrison From: g_harrison@vger.nsu.edu Newsgroups: comp.lang.pascal Subject: UNtagged variant records and JPAM Message-ID: <225.273b14fa@vger.nsu.edu> Date: 10 Nov 90 00:43:38 GMT Lines: 65 Untagged variant records have been used for years to do special things like bit twiddling and demonstrating the implementation of data types - - as in const IntSize = ....... {size of an INTEGER} type FunnyRecord = record case BOOLEAN of TRUE : ( BITS: packed array [0..IntSize-1] of 0..1 ); FALSE : ( INT : INTEGER ) end; var Fun : FunnyRecord; .... Fun.INT := 17; Writing out Fun.BITS gives the bit representation of Fun.INT -- or does it? I've seen some Pascal compilers give some strange data here. 1. Although I can't find it in Wirth and Jansen (ISO STANDARD), is there a guarantee that this will give the bit implementation of the integer? 2. It works great on VAX Pascal for all appropriate data types. I can also get POINTER values this way -- all in ISO STANDARD: type Pointer = record case BOOLEAN of TRUE : (INT : INTEGER); FALSE : (P : ^INTEGER) end; var PTR : Pointer; .... NEW(PTR.P); WRITE(PTR.INT) {writes the pointer (or address offset) value} Are all the texts that say that one can't write out the value of a pointer in standard Pascal in error? 2. Besides BitTwiddling and making interesting demonstrations to students, are there other uses for untagged variant records? 3. Virtually every Pascal text WARNS against using these records. It almost seems like an ERROR on Wirth's part or the ISO Standard's committee part. Was it a boo boo that became "popular" (like CREAT in Uniques)? 4. I first saw some of this stuff in the Journal of Pascal, Ada and Modula-2 (JPAM). I haven't received my JPAM in almost a year - and I had about a year to go on my subscription and have received no renewal notice. Does anyone know if it still exists? George...... -------------------------------------------------------------------------- -- George C. Harrison INTERNET: g_harrison@vger.nsu.EDU -- -- Professor of Computer Science Subliminal Address: adA -- -- Norfolk State University -- -- The views expressed here are not necessarily those of -- -- the Univesity, my wife, or my children. -- --------------------------------------------------------------------------