comp.lang.ada
 help / color / mirror / Atom feed
* array size
@ 1999-12-10  0:00 James E. Hopper
  1999-12-10  0:00 ` Matthew Heaney
  1999-12-11  0:00 ` DuckE
  0 siblings, 2 replies; 15+ messages in thread
From: James E. Hopper @ 1999-12-10  0:00 UTC (permalink / raw)


the following program is a cut and paste from some code we are porting
to gnat from vads.  if some reason the type

 type Day_Array_Type is array ( Day_Type ) of Preset_Array_Type;
  pragma pack (Day_Array_Type);  -- RAD SOLARIS PORT

is not packing the array how i would expect.  it appears to be padding
each element with 2 bytes to align array elements on word boundries
despite the pragma pack.  using rep spec doesnt help because compiler
spits it out as wrong size.

any ideas???

thansk jim

-----------------

with text_io;


procedure  test is

   type Integer_Type is range -32_768..32_767;
   for Integer_Type' Size use 16;
   --
   -- Integer_type will take the place of Standard Integer and it
   -- will be confined to 16 bits.
   --
    
   subtype Natural_Type is Integer_Type range  0..32_767;
   --
   -- Natural_type will take the place of Standard Natural and it
   -- will be confined to 16 bits.
   --

   subtype Positive_Type is Integer_Type range  1..32_767;
   --
   -- Positive_type will take the place of Standard Positive and it
   -- will be confined to 16 bits.
   --
  Byte_Size : constant Positive_Type := 8;

  type Frequency_Type is range 0..399975;
  for Frequency_Type' Size use 3 * Byte_Size;

  type Preset_Type is ( Pset20, Pset19, Pset18, Pset17, Pset16, Pset15
);
  type Preset_Array_Type is array ( Preset_Type ) of Frequency_Type;
  pragma pack (Preset_Array_Type);  -- RAD SOLARIS PORT
  for Preset_Array_Type'Size use 6 * Frequency_Type'Size;

  type Day_Type is ( Day1, Day2, Day3, Day4, Day5, Day6, Day7 );
  type Day_Array_Type is array ( Day_Type ) of Preset_Array_Type;
  pragma pack (Day_Array_Type);  -- RAD SOLARIS PORT
-- I had to comment out this next line to get my little test program to
compile, this
-- is straight from a real example.  For some reason the compiler
thinks Day_Array_Type
-- needs to be 1120 bits, even when I pack it.
-- Rick and I did a little calculating and the difference is 112, which
is 7 * 16,
-- or 2 extra bytes per array element.  If you take the 144 (size of
each elem) + 16,
-- gives you 160, or 5 words.  So, we're guessing the compiler is
lining up each 
-- array element on a word boundary (ie it seems to be ignoring my pack!
--  for Day_Array_Type'Size use 7 * 18 * Byte_Size;

-- We tried the following just for giggles but interestingly, the
compiler 
-- says that Preset_Array_Type'Size isn't static!!
--  for Day_Array_Type'Size use 7 * Preset_Array_Type'Size;

begin

text_io.put ("Size of Frequency Type = ");
text_io.put (integer'image (Frequency_Type'size));
text_io.new_line;
text_io.new_line;

text_io.put ("Length of Preset_Array_Type = ");
text_io.put (integer'image (Preset_Array_Type'Length));
text_io.new_line;
text_io.put ("Size of Preset array elems (Frequency_Type) * length of
array = ");
text_io.put (integer'image (Frequency_Type'Size *
Preset_Array_Type'Length));
text_io.new_line;
text_io.put ("Size of Preset_Array_Type (per compiler- should match
above calculation = ");
text_io.put (integer'image (Preset_Array_Type'size));
text_io.new_line;
text_io.new_line;

text_io.put ("Length of Day_Array_Type = ");
text_io.put (integer'image (Day_Array_Type'Length));
text_io.new_line;
text_io.put ("Size of day array elems (Preset_Array _Type) * length of
array = ");
text_io.put (integer'image (Preset_Array_Type'Size *
Day_Array_Type'Length));
text_io.new_line;
text_io.put ("Size of Day_Array_Type (per compiler- should match above
calculation = ");
text_io.put (integer'image (Day_Array_Type'size));
text_io.new_line;


end test;




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: array size
  1999-12-10  0:00 array size James E. Hopper
@ 1999-12-10  0:00 ` Matthew Heaney
  1999-12-11  0:00   ` Robert Dewar
  1999-12-11  0:00   ` James E. Hopper
  1999-12-11  0:00 ` DuckE
  1 sibling, 2 replies; 15+ messages in thread
From: Matthew Heaney @ 1999-12-10  0:00 UTC (permalink / raw)


In article <101219991605504828%hopperj@macconnect.com> , "James E. 
Hopper" <hopperj@macconnect.com> wrote:

>   type Preset_Array_Type is array ( Preset_Type ) of Frequency_Type;
>   pragma pack (Preset_Array_Type);  -- RAD SOLARIS PORT
>   for Preset_Array_Type'Size use 6 * Frequency_Type'Size;

Always do this for composite types:

  Preset_Array_Type_Size : constant := 6 * Frequency_Type'Size;
  for Preset_Array_Type'Size use Preset_Array_Type_Size;


> -- We tried the following just for giggles but interestingly,
> -- the compiler says that Preset_Array_Type'Size isn't static!!
> -- for Day_Array_Type'Size use 7 * Preset_Array_Type'Size;

It said that because composite types (including arrays) are always
nonstatic; see RM95 4.9.

The solution is easy enough:

  for Day_Array_Type'Size use 7 * Preset_Array_Type_Size;

or better

  Day_Array_Type_Size : constant := 7 * Preset_Array_Type_Size;
  for Day_Array_Type'Size use Day_Array_Type_Size;


--
Time and again the nation's courts have ruled that creationism, as a
religious dogma, cannot be taught in science classes. Now, creationists
are advancing a new tactic: eliminating the teaching of evolution and
other sciences that complement evolution, such as geology, paleontology,
and biological anthropology. By doing so, they are not only endangering
church-state separation but also seriously jeopardizing the science
education of future generations.

http://www.campusfreethought.org/sos/




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: array size
  1999-12-10  0:00 array size James E. Hopper
  1999-12-10  0:00 ` Matthew Heaney
@ 1999-12-11  0:00 ` DuckE
  1999-12-11  0:00   ` James E. Hopper
  1 sibling, 1 reply; 15+ messages in thread
From: DuckE @ 1999-12-11  0:00 UTC (permalink / raw)


Here's my results with GNAT 3.12p on Windows NT:

-----------------
Size of Frequency Type =  24

Length of Preset_Array_Type =  6
Size of Preset array elems (Frequency_Type) * length of array =  144
Size of Preset_Array_Type (per compiler- should match above calculation =
144

Length of Day_Array_Type =  7
Size of day array elems (Preset_Array _Type) * length of array =  1008
Size of Day_Array_Type (per compiler- should match above calculation =  1008
------------------

It looks like this is what you were expecting.  What's your host/target?

SteveD

James E. Hopper <hopperj@macconnect.com> wrote in message
news:101219991605504828%hopperj@macconnect.com...
> the following program is a cut and paste from some code we are porting
> to gnat from vads.  if some reason the type
>
>  type Day_Array_Type is array ( Day_Type ) of Preset_Array_Type;
>   pragma pack (Day_Array_Type);  -- RAD SOLARIS PORT
>
> is not packing the array how i would expect.  it appears to be padding
> each element with 2 bytes to align array elements on word boundries
> despite the pragma pack.  using rep spec doesnt help because compiler
> spits it out as wrong size.
>
> any ideas???
>
> thansk jim
[snip]






^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: array size
  1999-12-11  0:00   ` Robert Dewar
  1999-12-11  0:00     ` James E. Hopper
@ 1999-12-11  0:00     ` Robert A Duff
  1999-12-11  0:00       ` Matthew Heaney
  1999-12-11  0:00     ` Matthew Heaney
  2 siblings, 1 reply; 15+ messages in thread
From: Robert A Duff @ 1999-12-11  0:00 UTC (permalink / raw)


Robert Dewar <robert_dewar@my-deja.com> writes:

> In article <3851d15b_1@news1.prserv.net>,
>   "Matthew Heaney" <matthew_heaney@acm.org> wrote:
> > >   for Preset_Array_Type'Size use 6 * Frequency_Type'Size;
> >
> > Always do this for composite types:
> >
> >   Preset_Array_Type_Size : constant := 6 *
> Frequency_Type'Size;
> >   for Preset_Array_Type'Size use Preset_Array_Type_Size;
> 
> 
> This is incomprehensible advice, these are obviously equivalent.
> Both will of course be illegal if Frequency_Type'Size is not
> static ... Matthew what are you trying to say here?

I stared at that one for a long time before I realized -- I think what
he's trying to accomplish is that you can elsewhere refer to the size of
Preset_Array_Type in a static expression (perhaps in some other rep
clause).  "Preset_Array_Type'Size" won't work, because it's not static.
You obviously don't want to write "6 * Frequency_Type'Size" more than
once in the program.  He's come up with a coding convention that ensures
you can always say "Preset_Array_Type_Size" to get the size of an array
as a static expression.

- Bob




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: array size
  1999-12-11  0:00   ` Robert Dewar
  1999-12-11  0:00     ` James E. Hopper
  1999-12-11  0:00     ` Robert A Duff
@ 1999-12-11  0:00     ` Matthew Heaney
  1999-12-13  0:00       ` Robert A Duff
  2 siblings, 1 reply; 15+ messages in thread
From: Matthew Heaney @ 1999-12-11  0:00 UTC (permalink / raw)


In article <82to3s$ng7$1@nnrp1.deja.com> , Robert Dewar 
<robert_dewar@my-deja.com>  wrote:

>> Always do this for composite types:
>>
>>   Preset_Array_Type_Size : constant := 6 * Frequency_Type'Size;
>>   for Preset_Array_Type'Size use Preset_Array_Type_Size;
>
>
> This is incomprehensible advice, these are obviously equivalent.
> Both will of course be illegal if Frequency_Type'Size is not
> static ... Matthew what are you trying to say here?

You have to look at my whole example.  The reason you use the locution
above, is so that you can refer to the static constant in other type
declarations.

(The constant to specify the value of T'Size is static, yet the
expression T'Size is nonstatic, because T is a nonstatic type.  I don't
understand the rationale for such an odd language feature.)

In this particular example, Frequency_Type'Size is static (because it's
a static scalar type).  So you can use it as the value of a (static)
named number; here, the size of the Preset_Array_Type.

You use the static named number when you declare an array (or record)
type that contains Preset_Array_Type as a component:

  type T is array (1 .. 10) of Preset_Array_Type;
  for T'Component_Size use Preset_Array_Type_Size;
  for T'Size use 10 * Preset_Array_Type_Size;

Note that we refer to the static constant, not to the size attribute
directly.  In other words, this ...

  type T is array (1 .. 10) of Preset_Array_Type;
  for T'Component_Size use Preset_Array_Type'Size;
  for T'Size use 10 * Preset_Array_Type'Size;

... won't compile.  Don't ask me why the language was designed this way,
because it makes no sense to me!

RM83 4.9 was too conservative wrt what's officially static, and RM95 4.9
improved things, but RM95 4.9 is still too conservative.  There's no
obvious reason I have to use the locution above (always declare a static
constant for composite type sizes, and refer to the constant instead of
T'Size).  What's "incomprehensible" is the rationale for not allowing
some composite types to be officially static.

--
I see no good reasons why the views given in this volume should shock
the religious feelings of anyone.

Charles Darwin, The Origin of Species




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: array size
  1999-12-11  0:00     ` Robert A Duff
@ 1999-12-11  0:00       ` Matthew Heaney
  0 siblings, 0 replies; 15+ messages in thread
From: Matthew Heaney @ 1999-12-11  0:00 UTC (permalink / raw)


In article <wccln71to2l.fsf@world.std.com> , Robert A Duff 
<bobduff@world.std.com>  wrote:

>> > Always do this for composite types:
>> >
>> >   Preset_Array_Type_Size : constant := 6 * Frequency_Type'Size;
>> >   for Preset_Array_Type'Size use Preset_Array_Type_Size;
>
> I stared at that one for a long time before I realized -- I think what
> he's trying to accomplish is that you can elsewhere refer to the size of
> Preset_Array_Type in a static expression (perhaps in some other rep
> clause).  "Preset_Array_Type'Size" won't work, because it's not static.
> You obviously don't want to write "6 * Frequency_Type'Size" more than
> once in the program.  He's come up with a coding convention that ensures
> you can always say "Preset_Array_Type_Size" to get the size of an array
> as a static expression.

Yes.  That's what I showed in the latter part of the example:

>   for Day_Array_Type'Size use 7 * Preset_Array_Type_Size;


--
Help keep evolution in the science classroom and religion out: become a
member of the National Center for Science Education.

<http://www.natcenscied.org/>





^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: array size
  1999-12-11  0:00 ` DuckE
@ 1999-12-11  0:00   ` James E. Hopper
  1999-12-11  0:00     ` DuckE
  0 siblings, 1 reply; 15+ messages in thread
From: James E. Hopper @ 1999-12-11  0:00 UTC (permalink / raw)


Steve,
that pretty much answers my question about it being a bug in machten. 
the problem arose initially on solaris (it was sent to me as a
question) and the machten port gives the same answer as the solaris
port. but if NT gives the expected answer then there is possibly
something wrong with gnat???  I will send it on to ACT

THANKS!  jim


In article <3852831a.0@news.pacifier.com>, DuckE
<nospam_steved@pacifier.com> wrote:

> Here's my results with GNAT 3.12p on Windows NT:
> 
> -----------------
> Size of Frequency Type =  24
> 
> Length of Preset_Array_Type =  6
> Size of Preset array elems (Frequency_Type) * length of array =  144
> Size of Preset_Array_Type (per compiler- should match above calculation =
> 144
> 
> Length of Day_Array_Type =  7
> Size of day array elems (Preset_Array _Type) * length of array =  1008
> Size of Day_Array_Type (per compiler- should match above calculation =  1008
> ------------------
> 
> It looks like this is what you were expecting.  What's your host/target?
> 
> SteveD
> 
> James E. Hopper <hopperj@macconnect.com> wrote in message
> news:101219991605504828%hopperj@macconnect.com...
> > the following program is a cut and paste from some code we are porting
> > to gnat from vads.  if some reason the type
> >
> >  type Day_Array_Type is array ( Day_Type ) of Preset_Array_Type;
> >   pragma pack (Day_Array_Type);  -- RAD SOLARIS PORT
> >
> > is not packing the array how i would expect.  it appears to be padding
> > each element with 2 bytes to align array elements on word boundries
> > despite the pragma pack.  using rep spec doesnt help because compiler
> > spits it out as wrong size.
> >
> > any ideas???
> >
> > thansk jim
> [snip]




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: array size
  1999-12-10  0:00 ` Matthew Heaney
  1999-12-11  0:00   ` Robert Dewar
@ 1999-12-11  0:00   ` James E. Hopper
  1 sibling, 0 replies; 15+ messages in thread
From: James E. Hopper @ 1999-12-11  0:00 UTC (permalink / raw)



well i tried adding

  for Day_Array_Type'Size use 7 * Preset_Array_Type_Size;

this won't compile either. i get:
test.adb:48:33: size for "Day_Array_Type" too small, minimum allowed is
1120
gnatmake: "test.adb" compilation error

could this be a gnat bug??

jim


In article <3851d15b_1@news1.prserv.net>, Matthew Heaney
<matthew_heaney@acm.org> wrote:

> In article <101219991605504828%hopperj@macconnect.com> , "James E. 
> Hopper" <hopperj@macconnect.com> wrote:
> 
> >   type Preset_Array_Type is array ( Preset_Type ) of Frequency_Type;
> >   pragma pack (Preset_Array_Type);  -- RAD SOLARIS PORT
> >   for Preset_Array_Type'Size use 6 * Frequency_Type'Size;
> 
> Always do this for composite types:
> 
>   Preset_Array_Type_Size : constant := 6 * Frequency_Type'Size;
>   for Preset_Array_Type'Size use Preset_Array_Type_Size;
> 
> 
> > -- We tried the following just for giggles but interestingly,
> > -- the compiler says that Preset_Array_Type'Size isn't static!!
> > -- for Day_Array_Type'Size use 7 * Preset_Array_Type'Size;
> 
> It said that because composite types (including arrays) are always
> nonstatic; see RM95 4.9.
> 
> The solution is easy enough:
> 
>   for Day_Array_Type'Size use 7 * Preset_Array_Type_Size;
> 
> or better
> 
>   Day_Array_Type_Size : constant := 7 * Preset_Array_Type_Size;
>   for Day_Array_Type'Size use Day_Array_Type_Size;
> 
> 
> --
> Time and again the nation's courts have ruled that creationism, as a
> religious dogma, cannot be taught in science classes. Now, creationists
> are advancing a new tactic: eliminating the teaching of evolution and
> other sciences that complement evolution, such as geology, paleontology,
> and biological anthropology. By doing so, they are not only endangering
> church-state separation but also seriously jeopardizing the science
> education of future generations.
> 
> http://www.campusfreethought.org/sos/




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: array size
  1999-12-11  0:00   ` Robert Dewar
@ 1999-12-11  0:00     ` James E. Hopper
  1999-12-12  0:00       ` Matthew Heaney
  1999-12-11  0:00     ` Robert A Duff
  1999-12-11  0:00     ` Matthew Heaney
  2 siblings, 1 reply; 15+ messages in thread
From: James E. Hopper @ 1999-12-11  0:00 UTC (permalink / raw)


Robert, i am confused.  whey would 

 Preset_Array_Type_Size : constant := 6 * Frequency_Type'Size;

be illegal in this context? 

thanks jim

------------

In article <82to3s$ng7$1@nnrp1.deja.com>, Robert Dewar
<robert_dewar@my-deja.com> wrote:

> > Always do this for composite types:
> >
> >   Preset_Array_Type_Size : constant := 6 *
> Frequency_Type'Size;
> >   for Preset_Array_Type'Size use Preset_Array_Type_Size;
> 
> 
> This is incomprehensible advice, these are obviously equivalent.
> Both will of course be illegal if Frequency_Type'Size is not
> static ... Matthew what are you trying to say here?




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: array size
  1999-12-11  0:00   ` James E. Hopper
@ 1999-12-11  0:00     ` DuckE
  1999-12-12  0:00       ` James E. Hopper
  1999-12-12  0:00       ` Matthew Heaney
  0 siblings, 2 replies; 15+ messages in thread
From: DuckE @ 1999-12-11  0:00 UTC (permalink / raw)


BTW: When I tested your code on NT I was guessing that I would need some
sort of component_size representation clause in the array declaration (as
has been described in the 3 bit array thread).  I was actually suprised at
my result.

SteveD

James E. Hopper <hopperj@macconnect.com> wrote in message
news:111219991626405236%hopperj@macconnect.com...
> Steve,
> that pretty much answers my question about it being a bug in machten.
> the problem arose initially on solaris (it was sent to me as a
> question) and the machten port gives the same answer as the solaris
> port. but if NT gives the expected answer then there is possibly
> something wrong with gnat???  I will send it on to ACT
>
> THANKS!  jim
>
>







^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: array size
  1999-12-10  0:00 ` Matthew Heaney
@ 1999-12-11  0:00   ` Robert Dewar
  1999-12-11  0:00     ` James E. Hopper
                       ` (2 more replies)
  1999-12-11  0:00   ` James E. Hopper
  1 sibling, 3 replies; 15+ messages in thread
From: Robert Dewar @ 1999-12-11  0:00 UTC (permalink / raw)


In article <3851d15b_1@news1.prserv.net>,
  "Matthew Heaney" <matthew_heaney@acm.org> wrote:
> >   for Preset_Array_Type'Size use 6 * Frequency_Type'Size;
>
> Always do this for composite types:
>
>   Preset_Array_Type_Size : constant := 6 *
Frequency_Type'Size;
>   for Preset_Array_Type'Size use Preset_Array_Type_Size;


This is incomprehensible advice, these are obviously equivalent.
Both will of course be illegal if Frequency_Type'Size is not
static ... Matthew what are you trying to say here?


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: array size
  1999-12-11  0:00     ` James E. Hopper
@ 1999-12-12  0:00       ` Matthew Heaney
  0 siblings, 0 replies; 15+ messages in thread
From: Matthew Heaney @ 1999-12-12  0:00 UTC (permalink / raw)


In article <111219991626304637%hopperj@macconnect.com> , "James E. 
Hopper" <hopperj@macconnect.com> wrote:

> Robert, i am confused.  whey would
>
>  Preset_Array_Type_Size : constant := 6 * Frequency_Type'Size;
>
> be illegal in this context?

It's legal, because Frequency_Type is a static subtype.




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: array size
  1999-12-11  0:00     ` DuckE
  1999-12-12  0:00       ` James E. Hopper
@ 1999-12-12  0:00       ` Matthew Heaney
  1 sibling, 0 replies; 15+ messages in thread
From: Matthew Heaney @ 1999-12-12  0:00 UTC (permalink / raw)


In article <38532c6a.0@news.pacifier.com> , "DuckE" 
<nospam_steved@pacifier.com> wrote:

> BTW: When I tested your code on NT I was guessing that I would need some
> sort of component_size representation clause in the array declaration (as
> has been described in the 3 bit array thread).  I was actually suprised at
> my result.

In general, if you want to completely specify the representation of the
type, you should specify everything, including the Component_Size.

Use pragma Pack when you want to optimize for space, and when you don't
care about exact representation.




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: array size
  1999-12-11  0:00     ` DuckE
@ 1999-12-12  0:00       ` James E. Hopper
  1999-12-12  0:00       ` Matthew Heaney
  1 sibling, 0 replies; 15+ messages in thread
From: James E. Hopper @ 1999-12-12  0:00 UTC (permalink / raw)


Well i have been told that pragma pack was machine dependent in what it
does in this program.  gee imaging that pragma pack doesnt ;-)  so i
tried component size with form all of the allowed values none of them
made the slightest difference in every case each array element which
was an array is padded with 2 bytes.  i am stumped, there doesnt seem
to be anyway to create and array of arrays and define the byte
alignmented fully that i can find, or that anyone can suggest.  this is
a piece of working vads code so changing the data structure ripples
through a lot of other things  and is not a welcome solution!  

jim


In article <38532c6a.0@news.pacifier.com>, DuckE
<nospam_steved@pacifier.com> wrote:

> BTW: When I tested your code on NT I was guessing that I would need some
> sort of component_size representation clause in the array declaration (as
> has been described in the 3 bit array thread).  I was actually suprised at
> my result.




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: array size
  1999-12-11  0:00     ` Matthew Heaney
@ 1999-12-13  0:00       ` Robert A Duff
  0 siblings, 0 replies; 15+ messages in thread
From: Robert A Duff @ 1999-12-13  0:00 UTC (permalink / raw)


"Matthew Heaney" <matthew_heaney@acm.org> writes:

> RM83 4.9 was too conservative wrt what's officially static, and RM95 4.9
> improved things, but RM95 4.9 is still too conservative.  There's no
> obvious reason I have to use the locution above (always declare a static
> constant for composite type sizes, and refer to the constant instead of
> T'Size).  What's "incomprehensible" is the rationale for not allowing
> some composite types to be officially static.

It does seem odd.

However, I think there are some reasons for it.  For one thing, it
simplifies the description of the rules.  Clearly T'Size can be static
if T is a dynamic array, or a a record containing discriminant-dependent
arrays.  Also, T'Size can't be static if any of the component types are
private, or partly private.  Writing down exactly when T'Size can be
static for records would be a pain.

Another thing is that T'Size for records is highly machine dependent --
it depends on alignment considerations, for example.  Therefore, you
would like to determine T'Size in the back end of the compiler.  But
static expressions have to be evaluated in the front end of the
compiler, because they affect overload resolution (of weird things like
A'First(T'Size)), and they affect various legality rules.

For scalar types, on the other hand, 'Size is not quite so hardware
dependent.  Especially with the Ada 95 rules, where, for example, the
Size of an integer type is pretty much determined by its range.
(Well, *almost*.  Allowing *any* 'Size to be static seems annoying to
me, as a compiler writer.)

So, implementing Scalar'Size in the front end isn't so horrible, whereas
implementing Record_Type'Size in the front end would damage the
structure of compilers.

Or are you suggesting that T'Size should be legal for records and arrays
if and only if T'Size was specified in a rep clause?  That could work,
but it also seems a little odd to me.

I believe that in an early version of Ada 9X, there were two kinds of
static expressions, in order to solve the above problem.  Record'Size
could be static in the sense that it affects generated code in a
compile-time-known way, but not in the legality-affecting or (shudder)
overload-resolution-affecting way.  I think this was rejected as being
overly complicated.

- Bob




^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~1999-12-13  0:00 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-10  0:00 array size James E. Hopper
1999-12-10  0:00 ` Matthew Heaney
1999-12-11  0:00   ` Robert Dewar
1999-12-11  0:00     ` James E. Hopper
1999-12-12  0:00       ` Matthew Heaney
1999-12-11  0:00     ` Robert A Duff
1999-12-11  0:00       ` Matthew Heaney
1999-12-11  0:00     ` Matthew Heaney
1999-12-13  0:00       ` Robert A Duff
1999-12-11  0:00   ` James E. Hopper
1999-12-11  0:00 ` DuckE
1999-12-11  0:00   ` James E. Hopper
1999-12-11  0:00     ` DuckE
1999-12-12  0:00       ` James E. Hopper
1999-12-12  0:00       ` Matthew Heaney

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