david@cernvax.UUCP (david) (07/13/84)
Using user defined types in type conversions in Modula-2 is definately asking for trouble. The problem is that the programs if transported to other computer systems, and therefore compilers, may not compile at all. Storage allocation of enumeration types is particulaly sensitive since some compilers will automatically allocate a word (say 16bits) for ALL enumeration types, wheras others will pack the enumerations into a byte if possible. Since the compilers are not supposed to do size conversion when type casting we end up in a bit of a mess !! What are we going to do when LONGINT and LONCARD become commonplace ? These should be 32 bit equivalents of the 16 bit INTEGER and CARDINAL types. Some implementations already define INTEGER and CARDINAL as 32 bit quantities. Will the following be allowed ? VAR i : LONGINT; j : INTEGER; BEGIN i := j; i := LONGINT(j); (* This may be an expression too ! *) j := INTEGER(i); END something. Strictly speaking that will not be allowed, but implementors must allow it if the language is to be usable. David Foster DD Division CERN 1211 Geneva 23 Switzerland