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,7a180be12347b9d3 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,7a180be12347b9d3 X-Google-Attributes: gid1108a1,public X-Google-ArrivalTime: 2002-02-08 01:46:21 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: dmitry@elros.cbb-automation.de (Dmitry A. Kazakov) Newsgroups: comp.lang.ada,comp.object Subject: Re: Merits of re-dispatching [LONG] Date: Fri, 08 Feb 2002 09:48:13 GMT Message-ID: <3c6397e5.3677906@News.CIS.DFN.DE> References: <3c62524f.93369796@News.CIS.DFN.DE> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) X-Trace: fu-berlin.de 1013161578 45394116 212.79.194.111 (16 [77047]) X-Newsreader: Forte Free Agent 1.21/32.243 Xref: archiver1.google.com comp.lang.ada:19759 comp.object:33649 Date: 2002-02-08T09:48:13+00:00 List-Id: On Thu, 7 Feb 2002 20:06:42 -0500, "Matthew Heaney" wrote: >"Dmitry A. Kazakov" wrote in message >news:3c62524f.93369796@News.CIS.DFN.DE... >> >> package Self_Identifying is >> type A is new >> Ada.Finalization.Limited_Controlled with private; >> type A_Ptr is access all A'Class; >> procedure Finalize (Object : in out A); >> procedure Foo (Object : in out A); >> private >> type A is new >> Ada.Finalization.Limited_Controlled with >> record >> Self : A_Ptr := A'Unchecked_Access; -- Class wide self-reference >> end record; >> end Self_Identifying; > >This is a horrible way to do this. Don't use a named access type when an >access discriminant will do: > > type Handle_Type (O : access A'Class) is limited null record; > > type A is new Limited_Controlled with record > H : Handle_Type (A'Access); > end record; I like it, but it has its own drawbacks. If only the component H should be exposed and all others be hidden, then one should make a lot of equilibristic: -- -- Public part of A -- type A_Public; type A_Handle (O : access A_Public'Class) is limited null record; type A_Public is abstract new Ada.Finalization.Limited_Controlled with record H : A_Handle (A_Public'Access); end record; procedure Foo (Object : in out A_Public) is abstract; -- -- Full A -- type A is new A_Public with private; type A_Ptr is access all A'Class; procedure Foo (Object : in out A); private type A is new A_Public with record ... -- private components; end record; But this is another question of course. >> Is there examples where re-dispatching is really unavoidable? > >There is a very simple solution to your problem: don't do it. So there is no such examples! (:-)) Regards, Dmitry Kazakov