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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,33afa3244ab891f7 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeedt0.toon.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Specialization generic package parameters Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1996bbhvwjxcr$.1s16brw83713g$.dlg@40tude.net> Date: Sat, 24 May 2008 10:00:52 +0200 Message-ID: <4s3i3iblzpe9$.11777ypdr70kr$.dlg@40tude.net> NNTP-Posting-Date: 24 May 2008 10:00:53 CEST NNTP-Posting-Host: 2ea2ead4.newsspool3.arcor-online.net X-Trace: DXC=W24XeAk:OeCWDmlTRbh@=IMcF=Q^Z^V3H4Fo<]lROoRA8kF?kNZ@K[6LHn;2LCVN[ On Fri, 23 May 2008 13:17:02 -0700 (PDT), christoph.grein@eurocopter.com wrote: > Why not a combination of 1+3: > > generic > type Some_S is new S with private; > package P.Q is > private > -- has access to the private part of P > end P.Q; But this would not constrain the parent P. A typical example for the case is implementation of parallel types hierarchies. For instance handles to the types T and S. (S <: T) generic type Some_T is new T with private; package P type T_Handle is private; procedure Foo (O : T_Handle); -- Delegation to Foo of T ... private type T_Ptr is not null access all Some_T'Class; type T_Handle is new Ada.Finalization.Controlled with record Ptr : T_Ptr; end record; end P; [ It is extremely tedious and error-prone to declare such delegation wrappers to all primitive operations of T, but there is no any help for this in Ada. ] Now, let S, derived from T adds some new operations and there should be specialized handles to S to accommodate to this: generic type Some_S is new S with private; package P type S_Handle is private; -- (or is new T_Handle with private) -- New operations: procedure Boo (O : S_Handle); -- Delegation to Boo of S -- Old operations from T: -- Oops, we should start all the mess again! -- It seems that there is no way to re-use the wrappers declared in P, -- by inheriting from T_Handle, without exposing private parts of -- T_Handle (the variant 1). Alternatively, S_Handle should leave the -- object pointer unconstrained, which would mean that delegators -- would have to downcast them to S'Class (=distributed performance -- hit) (the variant 3) procedure Foo (O : T_Handle); -- Delegation to Foo of T ... private ... end P; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de