From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3ccb707f4c91a5f2 X-Google-Attributes: gid103376,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: Portability of Arithmetic (was: Java vs Ada 95) Date: 1996/10/16 Message-ID: #1/1 X-Deja-AN: 189998325 references: <325D7F9B.2A8B@gte.net> <1996Oct15.174526.1@eisner> organization: New York University newsgroups: comp.lang.ada Date: 1996-10-16T00:00:00+00:00 List-Id: Bob Duff said type T is range 1..100; X: T := ...; Y: T := ...; Average: T := (X + Y) / 2; Because the above code will work fine on some Ada compilers, and blow up on others (the addition will overflow using 8-bit signed arithmetic) if X and Y happen to be, say, 99. In Java, the above code is guaranteed to work." I am not sure I understand Bob's statement here. The above code is certainly not valid Java code, so what does it mean to say that the above code works in Java. If you mean it is possible to write this in a manner that works in Java, then the same statement can be made in Ada: type BT is range 1 .. 200; subtype T is BT range 1 .. 100; X : T := ...; Y : T := ...; Average : T := (X + Y)/2; works fine. You can write invalid Ada code for anything, but doing so does not prove anything!