Xref: utzoo comp.lang.modula2:677 comp.lang.misc:1133 Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!lll-tis!ames!ptsfa!pacbell!att-ih!ihnp4!ihlpf!nevin1 From: nevin1@ihlpf.ATT.COM (00704a-Liber) Newsgroups: comp.lang.modula2,comp.lang.misc Subject: Re: From Modula to Oberon Message-ID: <3894@ihlpf.ATT.COM> Date: 4 Mar 88 01:29:19 GMT References: <7161@sol.ARPA> <2740@mmintl.UUCP> Reply-To: nevin1@ihlpf.UUCP (00704a-Liber,N.J.) Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 44 In article <2740@mmintl.UUCP> franka@mmintl.UUCP (Frank Adams) writes: .In article <7161@sol.ARPA> crowl@cs.rochester.edu (Lawrence Crowl) writes: .>[Text by Niklaus Wirth] .>With the proliferation of basic types, a relaxation of compatibility rules .>between them becomes almost mandatory. To this end, the notion of type .>inclusion is introduced: a type T includes a type T', if the values of T' .>are also values of type T. Oberon postulates the following hierarchy: .> LONGREAL > REAL > LONGINT > INTEGER > SHORTINT . .The basic problem is that the values of a 32 bit real do not include the .values of a 32 bit integer. If one is going to be meticulous enough about .assignments to define type inclusion, one should only make types be included .when they really are. This depends on what is meant by value. Including precision, you are right; n bit reals cannot exactly represent all the n bit integers. But, if you allow the precision to 'slack off', n bit reals CAN represent all the n bit integers. But the mapping is not 1:1; it is many:1 (from ints to reals); this means that in the following case: VAR IX, IY : INTEGER; {integers are 32 bits} RZ : REAL; {reals are 32 bits} ... {Somethings sets IX} ... RZ := IX; IY := INTEGER(RZ); IX and IY are not (necessarily) equal. But I wonder: in this circumstance, is it possible for the IY assignment statement to ever fail (ie, produce a run-time error)? I would hope not. A lot of people have praised Pascal and Modula-2 BECAUSE there were no implicit type conversions. Me, I'm not sure whether this is good or bad. Personally, I make most of my type conversions explicit anyway in most of the languages I use. Does it really add all that much complexity to the compiler; or, more importantly, does the compiler generate better code if the conversions are implicit (Personally, I can't see this happening)? -- _ __ NEVIN J. LIBER ..!ihnp4!ihlpf!nevin1 (312) 510-6194 ' ) ) "The secret compartment of my ring I fill / / _ , __o ____ with an Underdog super-energy pill." / (_