comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Why Ada is not the Commercial Lang of Choice
Date: 1997/06/20
Date: 1997-06-20T00:00:00+00:00	[thread overview]
Message-ID: <dewar.866864714@merv> (raw)
In-Reply-To: 33ab1c1c.2926201@news.mhv.net


Paul says

<<This is all well and good when you know the exact address to set the
variable to. The problem comes with a variable of type "address" that
you need to perform masking on. I was unable to re-cast a variable of
type "address" (which was derived from unsigned integer) to an
unsigned integer  so that I could mask out the lower 48 bits. That's
why I went the "unchecked conversion" route. Ada seems to be so
strictly typed that even though a variable is typed or sub-typed as
unsigned integer, it is treated as a completely different type than a
variable typed as unsigned integer.>>

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!





  reply	other threads:[~1997-06-20  0:00 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-06-18  0:00 Why Ada is not the Commercial Lang of Choice Robert I. Eachus
1997-06-18  0:00 ` Dale Stanbrough
1997-06-19  0:00   ` Robert A Duff
1997-06-21  0:00     ` Paul Van Bellinghen
1997-06-20  0:00       ` Robert Dewar [this message]
1997-06-23  0:00         ` John G. Volan
1997-07-03  0:00           ` Shmuel (Seymour J.) Metz
1997-07-03  0:00             ` Robert Dewar
1997-07-06  0:00               ` Yasmiin S. Davis
1997-07-06  0:00                 ` Robert Dewar
1997-07-07  0:00               ` Shmuel (Seymour J.) Metz
1997-07-04  0:00             ` Paul Van Bellinghen
1997-07-13  0:00               ` Ken Mays
1997-07-13  0:00                 ` Robert Munck
1997-07-14  0:00                   ` Ken Mays
1997-06-19  0:00   ` Steve Jones - JON
1997-06-19  0:00     ` Peter Hermann
1997-06-19  0:00     ` Anonymous
1997-07-17  0:00     ` Shmuel (Seymour J.) Metz
1997-06-20  0:00   ` Robert Dewar
1997-06-20  0:00   ` Don Harrison
1997-06-20  0:00     ` Larry Kilgallen
1997-06-20  0:00       ` Nick Leaton
1997-06-23  0:00       ` Don Harrison
1997-06-24  0:00         ` Bertrand Meyer
1997-06-24  0:00           ` Nick Leaton
1997-07-22  0:00           ` Dr. Vladimir Il'ich Fomin
1997-06-20  0:00     ` Donovan Baarda
1997-06-20  0:00     ` Roy Grimm
1997-06-23  0:00     ` Robert Dewar
1997-06-24  0:00       ` Don Harrison
1997-06-24  0:00         ` Robert Dewar
1997-06-23  0:00     ` Joachim Durchholz
1997-06-20  0:00 ` Robert Dewar
1997-06-21  0:00 ` Keith Thompson
1997-06-21  0:00   ` Robert Dewar
1997-06-24  0:00     ` Ken Garlington
1997-06-24  0:00       ` Robert Dewar
1997-06-28  0:00   ` Robert I. Eachus
1997-06-28  0:00     ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1997-06-13  0:00 Paul Van Bellinghen
1997-06-17  0:00 ` Robert Dewar
1997-06-20  0:00   ` nma123
1997-06-24  0:00     ` Adam Beneschan
1997-06-17  0:00 ` Dale Stanbrough
1997-06-17  0:00   ` Robert Munck
1997-06-18  0:00   ` Ken Garlington
1997-06-19  0:00     ` Ole-Hjalmar Kristensen FOU.TD/DELAB
1997-06-19  0:00       ` Ken Garlington
1997-06-18  0:00 ` Nick Roberts
1997-06-18  0:00   ` Peter Hermann
1997-06-20  0:00     ` Robert Dewar
1997-06-25  0:00     ` Van Snyder
1997-06-26  0:00       ` Robert Dewar
1997-06-30  0:00         ` Ralph Paul
1997-07-02  0:00           ` Joerg Rodemann
1997-07-02  0:00             ` Ralph Paul
1997-07-02  0:00             ` Joerg Rodemann
1997-06-19  0:00 ` Steve Doiel
1997-06-19  0:00   ` Anonymous
1997-07-22  0:00 ` Shmuel (Seymour J.) Metz
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox