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,9e2776c05028676e X-Google-Attributes: gid103376,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: Why Ada is not the Commercial Lang of Choice Date: 1997/06/20 Message-ID: #1/1 X-Deja-AN: 251497469 References: <33A7FBFF.29D2@mitre.org> <5o9eca$aoi$1@goanna.cs.rmit.edu.au> <33ab1c1c.2926201@news.mhv.net> Organization: New York University Newsgroups: comp.lang.ada Date: 1997-06-20T00:00:00+00:00 List-Id: Paul says <> Interesting that you choose an example where Ada has preferable semantics to C. In C there is no way to treat an address as an integer, except to do the equivalent of an unchecked conversion (i.e. a cast to an integral type). This cast is tricky, because (a) you have no way of declaring the integer type to which you will cast it in a portable manner. In fact it is not even required that there be such a type, though there usually will be (it might be int, or it might be long, or it might be long long). (b) when you do this cast in C, you have no idea what the equivalence will be, so as soon as you do things like masking out lower order bits you are in quite implementation dependent territory. Now obviously no language can guarantee portable semantics for this type of operation, but Ada does a much better job of providing appropriate semantic facilities here. In particular there is a defined type Integer_Address, which is precisely defined as an integer equivalent to a linear address, if this makes sense for the machine. And one can convert Address values to and from Integer_Address without using Unchecked_Conversion. Going the "unchecked conversion" route in Ada 83, which lacks this capability makes perfect sense, but how on earth could you present this as a difference between Ada and C. The unchecked conversion from integer to address in Ada has exactly the same semantics as the (unchecked) cast in C from integer to address. I often notice that when you get people to give actual examples in C of code that they would like to present as demonstrating the inadequacies of Ada, they actually turn out to be great examples of the superiority of Ada over C, in the realm which people think of as belonging to C, namely low level operations. That's why it is a shame that Joe will not or cannot follow through on giving specific examples. They very likely would be cases of this kind!