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=unavailable autolearn_force=no version=3.4.4 Path: backlog3.nntp.ams3.giganews.com!backlog3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Natasha Kerensikova Newsgroups: comp.lang.ada Subject: How to hide inherited implementation of a public interface? Date: Fri, 21 Mar 2014 12:53:45 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: Injection-Date: Fri, 21 Mar 2014 12:53:45 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="76a49b86bc3e16725b7cfca3d85cb4c8"; logging-data="4071"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Obd/C4nIbZOo7gw+uw8cJ" User-Agent: slrn/1.0.1 (FreeBSD) Cancel-Lock: sha1:R70vA8ZIomOxeq66/5I9YDFViGw= Xref: number.nntp.dca.giganews.com comp.lang.ada:185261 Date: 2014-03-21T12:53:45+00:00 List-Id: Hello, the subject contains my whole question, but since I'm afraid it might be ambiguous, let's consider the basic code below: package I is type T is interface; procedure P (Object : in out T) is abstract; end I; package A is type T is abstract new I.T with private; function F (Object : in T) return Integer is abstract; overriding procedure P (Object : in out T); private type A is abstract new I.T with record Value : Integer; end record; end A; package body A is overriding procedure P (Object : in out T) is Object.Value := F (T'Class (Object)); end P; end A; package C is type T is new I.T with private; -- What here? private type T is new A.T with record High : Boolean; end record overriding function F (Object : in T) return Integer; end C; package body C is overriding function F (Object : in T) return Integer is begin case Object.High is when True => return 1; when False => return -1; end case; end F; end C; There is a concrete type C.T, that publicly provides interface I.T, but internally uses inheritance to implement the interface. The fact that A.T is abstract is not directly relevant, I believe the situation is exactly the same with a concrete A.T, but it leaks the motivation behind such a construction. I could publicly derive C.T from A.T, and then everything would be fine. However in the particular case I encountered, it bothers me a bit to expose publicly that C.T is derived from A.T, since it really is an implementation detail. The only piece of information available to clients of C is supposed to be that I.T is implemented, no matter how. So is there a way to publicly provide I.T while privately inheriting almost everything from A.T? Thanks for your help, Natasha