comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: How I declare a 'mod' type within a record?
Date: 1997/07/31
Date: 1997-07-31T00:00:00+00:00	[thread overview]
Message-ID: <dewar.870363432@merv> (raw)
In-Reply-To: 33DF3FD2.20D2@mail.connect.usq.edu.au


Matthew says

<<Here is my code example, if you could examine it, I would be very
grateful :)  The compiler (GNAT) has fits when it sees the anonymous mod
type declared within the record making use of 'Size' - which is the
record parameter. >>

I am sure GNAT does not "have fits", but rather simply diagnoses your
obviously illegal code which bears no relation at all to legal Ada
syntax, with a clear message. I get:

     1. procedure Aging is
     2.
     3.    type Number is new Float;
     4.    type Buffer is array(Integer range <>) of Number;
     5.    type Time_Series(Size : Integer) is
     6.       record
     7.          History : Buffer(0..Size-1);
     8.          Head : mod Size;
                       |
        >>> subtype indication expected

     9.       end record;
    10.
    11.    X : Time_Series(3);
    12.
    13. begin
    14.    null;
    15. end;

And of course mod Size is not a subtype indication, or even close to one.

Modular types in Ada require that the modulus be a static expression.
This rule is quite clear in the reference manual. You need to study
modular types more carefully. When you do, you will see that they are
not particularly relevant to what you are trying to do here.

Records in Ada never allow anonymous types in any case, it is not clear
where you got the idea that they do, certainly you never saw any
examples like this. You might want to get a textbook with some clear
examples if reading the rules without examples is hard.





  parent reply	other threads:[~1997-07-31  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-07-30  0:00 How I declare a 'mod' type within a record? Matthew Kennedy
1997-07-30  0:00 ` Matthew Heaney
1997-07-31  0:00 ` Robert Dewar [this message]
1997-08-05  0:00 ` Mars Gralia
1997-08-05  0:00   ` John M. Mills
replies disabled

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