comp.lang.ada
 help / color / mirror / Atom feed
* saving variant records in sequential files
@ 1994-10-13  2:53 Hylton Raymond Peimer
  1994-10-13 10:46 ` Tucker Taft
  0 siblings, 1 reply; 2+ messages in thread
From: Hylton Raymond Peimer @ 1994-10-13  2:53 UTC (permalink / raw)


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));

or something similar.

Is Meridian wrong or is this an Ada83/9X feature?
--
   Hylton Peimer  --  s9406722@yallara.cs.rmit.edu.au  --  Team Ada!



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

* Re: saving variant records in sequential files
  1994-10-13  2:53 saving variant records in sequential files Hylton Raymond Peimer
@ 1994-10-13 10:46 ` Tucker Taft
  0 siblings, 0 replies; 2+ messages in thread
From: Tucker Taft @ 1994-10-13 10:46 UTC (permalink / raw)


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



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

end of thread, other threads:[~1994-10-13 10:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1994-10-13  2:53 saving variant records in sequential files Hylton Raymond Peimer
1994-10-13 10:46 ` Tucker Taft

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