comp.lang.ada
 help / color / mirror / Atom feed
From: crispen <@ada3.ca.boeing.com:crispen@eight-ball.boeing.com>
Subject: Forcing default representations
Date: Tue, 13 Jul 93 14:22:52 CDT	[thread overview]
Message-ID: <9307131922.AA04017@eight-ball.boeing.com> (raw)

OK, just what the hell does LRM 13.1(6) mean, anyway?

"certain occurrences of its name imply that the representation of the
type must have been determined."

Even the Annotated LRM is obscure on this point. "certain occurrences"
indeed!

My goal here is to put as many of my rep specs as I possibly can in
a private part.  In fact, I've been making some really sexy rep specs:

   for Trim_Max_Rate use
    record
      Aircraft_Trim_Positions
         at 0
         range 0..Aircraft_Trim_Position_Array_Size-1;
      Surface_Tab_Deflections
         at Aircraft_Trim_Position_Array_Size/8
         range 0..Surface_Tab_Deflection_Array_Size-1;
    end record;
   for Trim_Max_Rate'size use
      Aircraft_Trim_Position_Array_Size +
      Surface_Tab_Deflection_Array_Size;

Where I've defined the _Size constants elsewhere, e.g.:

   Aircraft_Trim_Position_Array_Size : constant :=
      Number_Of_Aircraft_Trims * Float_Size;
   for Aircraft_Trim_Position_Array'size use
      Aircraft_Trim_Position_Array_Size;

Like I said, pure sex -- oh, yeah, naturally I define:

   Number_Of_Aircraft_Trims : constant :=
      Aircraft_Trim'pos (Aircraft_Trim'last) -
      Aircraft_Trim'pos (Aircraft_Trim'first) + 1;

So basically I'm going after having the best of all possible worlds:
we have rep specs (essential, because we're defining objects that are
going on a network between two machines of possibly different
architectures), but the person who is modifying this file should
be able to add or delete from the Aircraft_Trim enumeration at will,
and the rep specs are generated automatically.  Cool!

In fact, I've tested this out on a SPARC, a 68030 board, and an
SGI Indigo, and it works!  Or, at any rate, when I define an object
of the type and have Text_IO put out the object'size/8 it gives
the same answer on all 3 machines.

The problem, though, is with this declaration:

   type Flight_Controls_Discrete_Outputs is (
      Flt_Control_System_Caution_Light,
      LE_Flaps_Caution_Light [...]

   Flight_Controls_Discrete_Outputs_Size : constant := 8;
   for Flight_Controls_Discrete_Outputs'size use
      Flight_Controls_Discrete_Outputs_Size;

If I define this above the private part, and before the declaration:

   type Flight_Controls_Discrete_Data_Pair is
   record
      Name  : Flight_Controls_Discrete_Outputs;
      State : Base_Types.Discrete_State;
    end record;

no problem.  If I don't, and if I define it in the private part, then
I get the following error:

/usr/people/crispen/generic/types/fc_if_types.a, line 372, char 5:error: RM 13.
1(6): type representation already determined by a forcing occurrence

on all 3 of my Ada compilers (they're VADS, but of different vintages).

But, I can define this record:

   for Landing_Gear_Parameters use
    record
      Position   at 0 range Four_Bytes;
      State      at 4 range One_Byte;
      -- 3 bytes spare
      Crab_Angle at 8 range Four_Bytes;
    end record;
   Landing_Gear_Parameters_Size : constant := 12 * Bytes;
   for Landing_Gear_Parameters'size use Landing_Gear_Parameters_Size;

in the private part with no problems (and Landing_Gear_Parameters is
defined as an element of another record before the private part).
You'd think that if one was a problem, so would the other one be,
but Nooooooo!

So, is my compiler ignoring the rep specs in the private part, or
what?

p.s.: I know I should substitute System.Storage_Unit for "8" above,
and I will.

p.p.s: I've defined:

   type One_Byte is range 0..7;
   type Two_Bytes is range 0..15;
   type Three_Bytes is range 0..23;
   type Four_Bytes is range 0..31;

Cute trick, eh?
+-------------------------------+--------------------------------------+
| Bob Crispen                   |   Who will babysit the babysitters?  |
| crispen@foxy.boeing.com       +--------------------------------------+
| (205) 461-3296                |Opinions expressed here are mine alone|
+-------------------------------+--------------------------------------+

             reply	other threads:[~1993-07-13 19:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-07-13 19:22 crispen [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-07-16 22:26 Forcing default representations dog.ee.lbl.gov!overload.lbl.gov!agate!howland.reston.ans.net!noc.near.net
1993-07-19 16:56 Adam Beneschan
1993-07-20 12:57 Bob Crispen
1993-07-22 18:34 Bob Crispen
1993-07-23 19:15 Gary Morris @ignite
1993-07-24 17:13 pipex!sunic!news.funet.fi!funic!news.eunet.fi!prime!mits!rkaivola
1993-07-24 21:16 Erik Magnuson
1993-07-26 15:12 agate!howland.reston.ans.net!europa.eng.gtefsd.com!news.ans.net!newsgate.watson.ibm.com!yktnews.watson.ibm.com!ncohen
1993-07-26 18:30 Robert I. Eachus
1993-07-30  1:15 pipex!warwick!zaphod.crihan.fr!univ-lyon1.fr!scsing.switch.ch!epflnews!di
1993-07-30 12:00 Bob Gilbert
replies disabled

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