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,fee8802cc3d8334d X-Google-Attributes: gid103376,public X-Google-Thread: 10a146,fee8802cc3d8334d X-Google-Attributes: gid10a146,public From: bill@world.nospam.com Subject: Re: Ada and Java. different behaviour. casting long to int problem. Date: 1999/06/16 Message-ID: <7k7ls5$15tv@drn.newsguy.com>#1/1 X-Deja-AN: 490178847 References: <7jt2c0$vrb@drn.newsguy.com> <7k57vb$1ipf@drn.newsguy.com> <3766650F.705125B7@pwfl.com> <7k64t7$igo$1@its.hooked.net> <7k689a$ci2@drn.newsguy.com> <3766C842.E1EAB60A@pwfl.com> <3766D1CC.D712895E@itools.symantec.com> Newsgroups: comp.lang.ada,comp.lang.java.programmer Date: 1999-06-16T00:00:00+00:00 List-Id: In article , Keith says... >My favorite compromise is the one that >says: > > For any arithmetic operation on integers, you will get the > mathematically correct result if it fits in the representation; > otherwise, you will be clearly informed that the implementation > was unable to do so (via an exception or some similar mechanism). > >For most purposes, I believe this is *better* than a compromise that >says, > > For any arithmetic operation on integers, you will get the > mathematically correct result if it fits in the representation; > otherwise, you will get a mathematically incorrect (but perhaps > well-defined) result, with no straightforward way to detect that > it's mathematically incorrect. > >Some people have argued that wraparound semantics, if >they're well-defined, are as "correct" as anything else. Sorry, but I >don't buy it. > Keith, The above is an excellent summary of this thread. I do not buy it either. no matter how many thousands of programmers go to JavaOne each year :) I think the bottom line of all of this, is that, it is OK if java will add 2 positives number and give back a negative number as a result, AS LONG AS the programmer has a way to be TOLD when this does happen, or a way to tell the compiler/run-time: please tell me when I make such a poopoo, or please do not tell me when I make a poopoo as I know what I am doing. Ada gives the programmer this choice. Java/C/C++ do NOT. For this, as someone else already said, Java is no better than C or C++ when those allow one to travel passed the array boundary WITHOUT TELLING the programmer that they just did that. In my eyes, there is absolutely no difference between the two situation, travelling passed array boundary == adding 2 positive numbers and giving a negative number. Why is it that java throws a run-time exception when one attempts to write passed array boundary, but closes it eyes when an overflow occurs? Based on this, I do not consider Java a safe language to use in applications requiring very safe and predictable behaviour. Bill