comp.lang.ada
 help / color / mirror / Atom feed
From: cis.ohio-state.edu!pacific.mps.ohio-state.edu!math.ohio-state.edu!howland
Subject: Re: Performing I/O on Private Types in Ada 9X (Was Re: OO Preprocessor for Ada)
Date: 23 Aug 93 16:03:33 GMT	[thread overview]
Message-ID: <CC7z9y.IJr@cs.uiuc.edu> (raw)

I like your example, but let me do a more concrete one.

Let's say I want to provide the capabilities of enumeration io for
my private type.  If type Object is not limited private, then
procedure Some_Client_With_Io_Removed can just instantiate enumeration_io:

with X;
with Text_Io;
procedure Some_Client_With_Io_Removed is
package X_Io is new 
	Text_Io.Enumeration_Io(	Enum=>	X.Object,
				Image=>	X.Object'Image,
     				Value=>	X.Object'Value); 
...
end Some_Client_With_Io_Removed;

But since X.Object is (tagged) limited private it is not so straight forward.
Using your example I need to do the following:

with Text_Io;
package X.Io is
	procedure Get(File: in Text_Io.In_File;Item: out Object);
        procedure Get(Item: out Object);
        procedure Put(File: in Text_Io.Out_File; Item: in Object;
                      Width: in Integer := 0;
                      Lower_Case: in Boolean := False);
        procedure Put(Item: in Object;
                      Width: in Integer := 0;
                      Lower_Case: in Boolean := False);
end X.Io;

with Text_Io;
package body X.Io is
	package Object_Io is new 
		Text_Io.Enumeration_Io(	Enum=>	X.Object,
					Image=>	X.Object'Image,
     					Value=>	X.Object'Value); 

	procedure Get(File: in Text_Io.In_File;Item: out Object) is
        	begin
                  Object_Io.Get(File;Item);
                end Get;
        procedure Get(Item: out Object) is
                begin
		  Object_Io.Get(Item);
                end Get;
        procedure Put(File: in Text_Io.Out_File; Item: in Object;
                      Width: in Integer := 0;
                      Lower_Case: in Boolean := False) is
                begin
                  Object_Io.Put(File; Item; Width; Lower_Case);
                end Put;
        procedure Put(Item: in Object;
                      Width: in Integer := 0;
                      Lower_Case: in Boolean := False) is
                begin
                  Object_Io.Put(Item; Width; Lower_Case);
                end Put;
end X.Io;

-------------------------------
What I'd really like to be able to do is

with Text_Io;
package X.Io is new 
	Text_Io.Enumeration_Io(	Enum=>	Object,
				Image=>	Object'Image,
     				Value=>	Object'Value);
end X.Io;

------
(1) Could I have used renames in the long example?

(2) Is the "really like to" example legal in 9X? (my feeling is that
it isn't).

Ken. 

             reply	other threads:[~1993-08-23 16:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-08-23 16:03 cis.ohio-state.edu!pacific.mps.ohio-state.edu!math.ohio-state.edu!howland [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-08-20 17:49 Performing I/O on Private Types in Ada 9X (Was Re: OO Preprocessor for Ada) cis.ohio-state.edu!magnus.acs.ohio-state.edu!math.ohio-state.edu!darwin.s
replies disabled

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