comp.lang.ada
 help / color / mirror / Atom feed
From: stt@dsd.camb.inmet.com (Tucker Taft)
Subject: Re: saving variant records in sequential files
Date: Thu, 13 Oct 1994 10:46:13 GMT
Date: 1994-10-13T10:46:13+00:00	[thread overview]
Message-ID: <CxLxx1.2zK@inmet.camb.inmet.com> (raw)
In-Reply-To: 37i7el$4gd@goanna.cs.rmit.oz.au

In article <37i7el$4gd@goanna.cs.rmit.oz.au>,
Hylton Raymond Peimer <s9406722@yallara.cs.rmit.OZ.AU> wrote:

>Hi you cool Ada programmer. Take a look at this:
>
>with sequential_io;
>
>procedure test is
>
>type data (info : integer) is record
>  case info is
>    when 1 => 
>      a : integer;
>      b : float;
>      c : natural;
>    when 2 =>
>      z : float;
>    when others => null;
>  end case;
>end record;
>
>package dat_file is new sequential_io(data); -- (1)
>
>begin
>  null;
>end test; 
>
>The package I created on line (1) wont compile under Meridian Ada compiler.
>It is because I haven't constrained it as:
>
>    package dat_file is new sequential_io(data(1));

That's not legal syntax, but I know what you mean...

>or something similar.
>
>Is Meridian wrong or is this an Ada83/9X feature?

In Ada 83, this sort of restriction was tacitly allowed (though discouraged).
In Ada 9X, the compiler must support instantiation of Sequential_IO
with an unconstrained type like yours.

Be that as it may, I suspect your file would be more useful
if you gave a default for the discriminant in the definition
of the type.  Otherwise, when you go to read data back from
the file, you will have to know in advance the particular discriminant
used to write out each record.

In any case, the answer is that Meridian would be "wrong" if it
were an Ada 9X compiler ;-).

>   Hylton Peimer  --  s9406722@yallara.cs.rmit.edu.au  --  Team Ada!

-Tucker Taft  stt@inmet.com



      reply	other threads:[~1994-10-13 10:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-10-13  2:53 saving variant records in sequential files Hylton Raymond Peimer
1994-10-13 10:46 ` Tucker Taft [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