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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bd913e780983783a,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-28 14:56:27 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!isdnet!enst!enst.fr!not-for-mail From: "Beard, Frank" Newsgroups: comp.lang.ada Subject: RE: Using renaming declarations to make private subprograms visib le Date: Tue, 28 Aug 2001 16:19:20 -0400 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: avanie.enst.fr 999034958 5981 137.194.161.2 (28 Aug 2001 21:42:38 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Tue, 28 Aug 2001 21:42:38 +0000 (UTC) To: "'comp.lang.ada@ada.eu.org'" Return-Path: X-Mailer: Internet Mail Service (5.5.2448.0) Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.4 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:12535 Date: 2001-08-28T16:19:20-04:00 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