comp.lang.ada
 help / color / mirror / Atom feed
From: "Beard, Frank" <beardf@spawar.navy.mil>
To: "'comp.lang.ada@ada.eu.org'" <comp.lang.ada@ada.eu.org>
Subject: RE: Using renaming declarations to make private subprograms visib le
Date: Tue, 28 Aug 2001 16:19:20 -0400
Date: 2001-08-28T16:19:20-04:00	[thread overview]
Message-ID: <mailman.999034905.16641.comp.lang.ada@ada.eu.org> (raw)

Matthew,

Have you tried fully qualified names, such as:

private

   type Token_Type is new Ada.Strings.Unbounded.Unbounded_String;

   function To_Token (Source : String) return Token_Type
     renames Ada.Strings.Unbounded.To_Unbounded_String;

   function To_String (Source : Token_Type) return String
     renames Ada.Strings.Unbounded.To_String;

   [...]

Frank

-----Original Message-----
From: Matthew Woodcraft [mailto:mattheww@chiark.greenend.org.uk]
Sent: Saturday, August 25, 2001 9:14 AM
To: comp.lang.ada@ada.eu.org
Subject: Using renaming declarations to make private subprograms visible



Suppose I want a private type that I can convert to a string and back:


package Foo is

   type Token_Type is private;

   function To_Token (Source : String) return Token_Type;

   function To_String (Source : Token_Type) return String;

   [...]

private

   [...]	

end Foo;



Now suppose that (for the moment), I want to implement this type using
an unbounded string. I can make Token_Type a derived type of
Unbounded_String, and use renaming declarations to make some of the
'inherited' subprograms publicly visible:

private

   type Token_Type is new Ada.Strings.Unbounded.Unbounded_String;

   function To_Token (Source : String) return Token_Type
     renames To_Unbounded_String;

    -- No good
   function To_String (Source : Token_Type) return String
     renames To_String;

   [...]


The trouble is, this doesn't work when I want the public name of a
subprogram to be the same as the private name (eg, To_String above), as
my new definition overrides the inherited one, and I end up trying
renaming the function to itself.

Is there any way to make the inherited subprogram publicly visible with
the same name? Or am I better off making Token_Type a record with one
component, rather than a derived type?


-M-
_______________________________________________
comp.lang.ada mailing list
comp.lang.ada@ada.eu.org
http://ada.eu.org/mailman/listinfo/comp.lang.ada



             reply	other threads:[~2001-08-28 20:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-28 20:19 Beard, Frank [this message]
2001-08-28 22:42 ` Using renaming declarations to make private subprograms visib le Matthew Woodcraft
2001-08-29  4:18   ` DuckE
  -- strict thread matches above, loose matches on Subject: below --
2001-08-29 17:26 Beard, Frank
replies disabled

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