comp.lang.ada
 help / color / mirror / Atom feed
From: ncohen@watson.ibm.com (Norman H. Cohen)
Subject: Re: An observation of Ada (may offend)
Date: 1995/03/27
Date: 1995-03-27T00:00:00+00:00	[thread overview]
Message-ID: <3l6sts$12kj@watnews1.watson.ibm.com> (raw)
In-Reply-To: 3l640c$308@miranda.gmrc.gecm.com

In article <3l640c$308@miranda.gmrc.gecm.com>, bill@valiant.gmrc.gecm.com
(R.A.L Williams) writes: 

|> I agree that the representation clauses defined in the LRM are splendid,
|> the problem is that they are *optional*. I don't know what the situation
|> is now, but when I last did a lot of work in Ada many compilers had only
|> a fragmentary coverage.

That is no longer the case.  In response to market forces, Ada compilers
have provided genuine support for record-representation clauses for many
years now.

In Ada 95, a compiler cannot claim conformance to the Systems Programming
Annex (and thus not to the Real-Time Systems annex) unless it supports
record-representation clauses.

|> Most of the time, as you say, bit fields are adequate, but how would you
|> implement ECC alogorithms or maximal length sequence generators for instance?
|> So far as standards are concerned, I believe that bit fields are codified
|> in the ANSI C standard, and every ANSI C compiler I've used actually does
|> implement them.

Yes, ANSI compilers must recognize bit-field declarations, but the ANSI C
standard imposes very few constraints on what the compiler is to do with
them.  In contrast, the Ada-83 rules (at least as interpreted by early
implementors) provided some leeway to reject a record-representation
clause, but an accepted record-representation clause provides an
unambiguous bit-by-bit specification of the intended layout.

It is easy to write Ada-83 record-representation clauses that produce
exactly the same layout for all compilers for, say, 32-bit big-endian
machines.  The Ada-95 pragma Bit_Order even makes it possible to write
clauses that are guaranteed to produce the same bit layout of a record on
all 32-bit machines (big-endian or little-endian).  (Of course you have
to decide what you mean by "the same" on big-endian and little-endian
machines, but whatever you decide, a record-representation clause can be
written to achieve it.)

ANSI C simply says that bit fields are packed as tightly as possible, in
order of declaration, into successive "units" with increasing addresses.
The ANSI C standard explicitly leaves all of the following unspecified: 

   - the size of the unit
   - the direction in which members packed into a single unit are laid
     out in that unit
   - whether a member that does not fit entirely in the current unit
     spans units or begins a new unit.  (A bit field of length zero
     forces a new unit to start, but there is no way to enforce spanning
     of units.)

--
Norman H. Cohen    ncohen@watson.ibm.com




  reply	other threads:[~1995-03-27  0:00 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-03-27 10:28 An observation of Ada (may offend) R.A.L Williams
1995-03-27  0:00 ` Norman H. Cohen [this message]
1995-04-04  0:00   ` Robert Dewar
1995-03-28 17:07 ` Larry Kilgallen, LJK Software
  -- strict thread matches above, loose matches on Subject: below --
1995-03-30  0:00 R.A.L Williams
1995-04-03  0:00 ` Norman H. Cohen
1995-03-29  0:00 R.A.L Williams
1995-03-27 10:38 R.A.L Williams
1995-03-30  3:14 ` Michael D. Griffin
1995-03-30  0:00   ` David Weller
1995-04-04  0:00   ` Brian Rogoff
1995-04-04  0:00   ` Jack Beidler
1995-03-17  9:27 R.A.L Williams
1995-03-17 15:23 ` Robb Nebbe
1995-03-17 17:08 ` Norman H. Cohen
1995-03-20  3:23   ` S. Tucker Taft
1995-03-20 10:13   ` Robb Nebbe
1995-03-21 21:05     ` Robert Dewar
1995-03-20 16:15   ` Robert I. Eachus
1995-03-21 19:47     ` Norman H. Cohen
1995-03-22  1:28       ` David Weller
1995-03-23  5:47       ` Robert Dewar
1995-03-23 16:38         ` Robert I. Eachus
1995-03-24 10:46           ` Peter Hermann
1995-03-24 16:52             ` David Weller
1995-03-26  4:03               ` Robert Dewar
1995-03-24 21:33             ` Tucker Taft
1995-03-27 18:58             ` Mark A Biggar
1995-03-24 19:45           ` Garlington KE
1995-03-27 19:58             ` Robert I. Eachus
1995-03-28 16:29               ` Garlington KE
1995-03-28 19:30                 ` Robert I. Eachus
1995-03-28 22:37                   ` Garlington KE
1995-03-29  8:31                   ` Robb Nebbe
1995-03-25 17:58           ` Robert Dewar
1995-03-26  6:20             ` R_Tim_Coslet
1995-03-27 20:38               ` Robert I. Eachus
1995-03-26  3:50           ` celier
     [not found]           ` <3l1lkq$pm6@gnat.csn <3l2o9a$3a1@infomatch.com>
1995-03-27 23:16             ` Robert Dewar
1995-03-23 18:05       ` John DiCamillo
1995-03-17 23:01 ` Larry Kilgallen, LJK Software
1995-03-18 12:41 ` Tucker Taft
1995-03-22 16:50 ` Renaud HEBERT
1995-03-23 23:23   ` John Volan
1995-03-24  0:38   ` Robert Dewar
1995-03-12 23:39 Matt Bruce
1995-03-13  0:34 ` David Weller
1995-03-14  4:49 ` Vladimir Vukicevic
1995-03-17 17:00   ` Michael Feldman
1995-03-17 13:09     ` Fred J. McCall
1995-03-18 20:34       ` Michael Feldman
1995-03-19 22:20         ` Robert Dewar
1995-03-20 17:19           ` Michael Feldman
1995-03-21 21:02             ` Robert Dewar
1995-03-21 23:01             ` Kevin F. Quinn
1995-03-22 12:43             ` Mike Meier
1995-03-20 20:38           ` Kevin F. Quinn
1995-03-21  3:02         ` Michael M. Bishop
1995-03-20  9:31       ` Robb Nebbe
1995-03-20 20:16       ` Mats Weber
1995-03-22 19:44       ` Stephen McNeill
1995-03-28 14:48       ` Wes Groleau
1995-03-22 17:20     ` Richard G. Hash
replies disabled

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