comp.lang.ada
 help / color / mirror / Atom feed
From: cis.ohio-state.edu!zaphod.mps.ohio-state.edu!wupost!uwm.edu!biosci!agate! linus!linus.mitre.org!maestro!jclander@ucbvax.Berkeley.EDU  (Julian C. Lander)
Subject: Re: HELP! Input/Output of private types
Date: 18 Nov 92 20:49:27 GMT	[thread overview]
Message-ID: <1992Nov18.204927.12829@linus.mitre.org> (raw)

In article <Bxpwty.H8E@acsu.buffalo.edu>, kist@acsu.buffalo.edu (james e kist) 
writes:
|> Someone please help! How can I use 'put' on a private type that is not
|> fully delcared in the specification? This is my situation:
|> 
|> generic
|> 	type Element is private;
|> package abcd
|> .
|> .
|> .
|> end abcd;
|> 
|> Now, how do I do I/O on an object that is of type Element? Thanks for any
|> help.

The short answer is that you can't.  The long answer is to change the
generic formal part so that it reads as follows:

generic
   type Element is private;
   with procedure Put_Element (File : in Text_IO.File_Type; The_Elt : in Elemen
t);
   with procedure Get_Element (File : in Text_IO.File_Type; The_Elt : out Eleme
nt);
package abcd
.
.
.
.
end abcd;

This means that the user of the generic package will need to supply
procedures for reading and writing data objects of type Element.  I'd
suggest including File in both profiles, since that lets you write to
any file.  To write to the standard output, you would say Put_Element
(Text_IO.Standard_Output, The_Elt).  (I suppose that even greater
generality would involve reading from and writing to strings, but I 
digress.)

Good luck.

Julian C. Lander
jclander@mitre.orgg

             reply	other threads:[~1992-11-18 20:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-11-18 20:49 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!wupost!uwm.edu!biosci!agate! [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-11-16 18:55 HELP! Input/Output of private types Bob Kitzberger
1992-11-16 16:11 Ron Sercely
1992-11-14 18:03 james e kist
replies disabled

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