From: Jerome Desquilbet <jDesquilbet@Rational.COM>
To: Ken Garlington <GarlingtonKE@lmtas.lmco.com>
Subject: Re: Question about record rep spec placement
Date: 1997/01/16
Date: 1997-01-16T00:00:00+00:00 [thread overview]
Message-ID: <32DE48C3.446B@Rational.COM> (raw)
In-Reply-To: 32DCFDAA.2656@lmtas.lmco.com
Ken Garlington wrote:
>
> We have some Ada83 code that looks like the following:
>
> package Some_Package is
>
> type Some_Record is record
> -- components here
> end record;
>
> -- some arbitrary declarations here
>
> private
>
> for Some_Record use record
> -- component rep spec here
> end record;
>
> end;
>
[...]
> when this code was compiled with an Ada 95 compiler, that the record
> rep spec had to be moved to immediately after the record declaration
> for the code to compile correctly.
This kind of contruction is legal in Ada 83 and in Ada 95.
And I think this is really good style: you may want to hide in a private
part the implementation details.
The following example compiles with my Ada 83 and Ada 95 compilers:
with System;
package Communication is
type Date is range 0 .. 3600;
type Word is range -(2 ** 31) .. (2 ** 31) - 1;
type Message is
record
Send_Date : Date;
Content : Word;
end record;
private
for Date'Size use 16;
for Word'Size use 32;
for Message use
record
Send_Date at 0 range 0 .. Date'Size - 1;
Content at (Date'Size / System.Storage_Unit)
range 0 .. Word'Size - 1;
end record;
for Message'Size use Date'Size + Word'Size;
end Communication;
You are able to document this as:
with System;
package Communication is
type Date is range 0 .. 3600;
type Word is range -(2 ** 31) .. (2 ** 31) - 1;
type Message is
record
Send_Date : Date;
Content : Word;
end record;
private
...
end Communication;
______________________________________________________________________
Jerome Desquilbet jDesquilbet@Rational.COM
' ^
prev parent reply other threads:[~1997-01-16 0:00 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-01-15 0:00 Question about record rep spec placement Ken Garlington
1997-01-15 0:00 ` Norman H. Cohen
1997-01-16 0:00 ` Ken Garlington
1997-01-17 0:00 ` Robert A Duff
1997-01-18 0:00 ` Ken Garlington
1997-01-15 0:00 ` Bob Gilbert
1997-01-16 0:00 ` Fergus Henderson
1997-01-17 0:00 ` Ken Garlington
1997-01-17 0:00 ` Bob Gilbert
1997-01-17 0:00 ` Robert A Duff
1997-01-17 0:00 ` Ken Garlington
1997-01-18 0:00 ` Robert A Duff
1997-01-18 0:00 ` Ken Garlington
1997-01-19 0:00 ` Robert A Duff
1997-01-21 0:00 ` Bob Gilbert
1997-01-22 0:00 ` Ken Garlington
1997-01-23 0:00 ` Art Schwarz
1997-01-25 0:00 ` Ken Garlington
1997-01-24 0:00 ` Bob Gilbert
1997-01-25 0:00 ` Ken Garlington
1997-01-20 0:00 ` Ken Garlington
1997-01-16 0:00 ` Jeff Creem
1997-01-16 0:00 ` Jerome Desquilbet [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox