comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: GNAT Ada for DOS - Reading Integers Problem
Date: 1996/02/21
Date: 1996-02-21T00:00:00+00:00	[thread overview]
Message-ID: <dewar.824941521@schonberg> (raw)
In-Reply-To: 4gfsuq$10f5@watnews1.watson.ibm.com

Norman said  Perhaps Robert is suggesting that the same effect could be achieved by
  writing
  
     type Half_Word is
        record
           Low  : Byte;
           High : Byte;
        end record;
  
     for Half_Word'Bit_Order use Low_Order_First;
  
     for Half_Word use
        record
           Low  at 0 range 0 .. 7;
           High at 0 range 8 .. 15;
        end record;
  
     type Byte_Swapped_Half_Word is new Half_Word;
  
     for Byte_Swapped_Half_Word'Bit_Order use High_Order_First;
  
  causing Byte_Swapped_Half_Word to inherit the literal text
  
      Low  at 0 range 0 .. 7;
      High at 0 range 8 .. 15;
  
  from its parent's record representation clause, but to interpret that
  text big-endianly instead of little-endianly!  This is certainly a
  creative interpretation, but I can't believe it is what the Founding
  Fathers intended.


Absolutely, that is what Robert is suggesting, and I can't manage to
read the intent of the RM any other way. When ytou derive, you inherit
the rep clauses, and then you can override any or all of them, and the
result is whatever you get from the mixture of inherited and overridden
rep clauses.

Now of course the above example is boring, since there are no fields
overlapping storage boundaries (and is thus incidentally trivial to
implement). The situation gets much more interesting with fields
that overlap storage boundaries, because then the non-default order
results in non-contiguous fields that are a real pain to implement.





  reply	other threads:[~1996-02-21  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4g2efj$d5d@susscsc1.rdg.ac.uk>
     [not found] ` <tgmDMwoGx.B04@netcom.com>
1996-02-20  0:00   ` GNAT Ada for DOS - Reading Integers Problem Dave Haverkamp
1996-02-20  0:00     ` Norman H. Cohen
1996-02-21  0:00       ` Robert Dewar
1996-02-21  0:00         ` Norman H. Cohen
1996-02-21  0:00           ` Robert Dewar [this message]
1996-02-23  0:00           ` Robert A Duff
1996-02-23  0:00             ` Robert Dewar
     [not found]         ` <Dn8ItA.B9H@world.std.com>
1996-02-23  0:00           ` Robert Dewar
1996-02-24  0:00 ` Tore Joergensen
replies disabled

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