From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,704a2a0ee079967,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-25 06:18:24 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!news1.ebone.net!news.ebone.net!diablo.netcom.net.uk!netcom.net.uk!btnet-peer!btnet!newspeer.clara.net!news.clara.net!news5-gui.server.ntli.net!ntli.net!news11-gui.server.ntli.net.POSTED!not-for-mail Sender: mjw@golux Newsgroups: comp.lang.ada Subject: Using renaming declarations to make private subprograms visible From: Matthew Woodcraft Message-ID: <87itfcnuyj.fsf@chiark.greenend.org.uk> User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: 25 Aug 2001 14:13:40 +0100 NNTP-Posting-Host: 213.107.104.73 X-Complaints-To: abuse@ntlworld.com X-Trace: news11-gui.server.ntli.net 998745202 213.107.104.73 (Sat, 25 Aug 2001 14:13:22 BST) NNTP-Posting-Date: Sat, 25 Aug 2001 14:13:22 BST Organization: ntl Cablemodem News Service Xref: archiver1.google.com comp.lang.ada:12411 Date: 2001-08-25T14:13:40+01:00 List-Id: 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-