comp.lang.ada
 help / color / mirror / Atom feed
From: dmitry@elros.cbb-automation.de (Dmitry A. Kazakov)
Subject: Re: Merits of re-dispatching [LONG]
Date: Fri, 08 Feb 2002 09:48:13 GMT
Date: 2002-02-08T09:48:13+00:00	[thread overview]
Message-ID: <3c6397e5.3677906@News.CIS.DFN.DE> (raw)
In-Reply-To: u668rmhvhdub11@corp.supernews.com

On Thu, 7 Feb 2002 20:06:42 -0500, "Matthew Heaney" <mheaney@on2.com>
wrote:

>"Dmitry A. Kazakov" <dmitry@elros.cbb-automation.de> 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



  reply	other threads:[~2002-02-08  9:48 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-07 10:26 Merits of re-dispatching [LONG] Dmitry A. Kazakov
2002-02-07 15:03 ` Hyman Rosen
2002-02-08  1:29   ` Matthew Heaney
2002-02-08  9:16     ` Dmitry A. Kazakov
2002-02-08 18:30       ` Hyman Rosen
2002-02-09  0:10         ` Matthew Heaney
2002-02-12  8:32         ` Dmitry A. Kazakov
2002-02-12 21:37           ` Hyman Rosen
2002-02-13  9:29             ` Dmitry A. Kazakov
2002-02-13 14:32               ` Hyman Rosen
2002-02-13 19:58           ` Dave Harris
2002-02-14 15:06             ` Dmitry A. Kazakov
2002-02-16 12:10               ` Dave Harris
2002-02-18  8:57                 ` Dmitry A. Kazakov
2002-02-18 19:47                   ` Merits of re-dispatching Dave Harris
2002-02-19  9:20                     ` Dmitry A. Kazakov
2002-02-21  5:49                       ` Hyman Rosen
2002-02-21  9:04                         ` Dmitry A. Kazakov
2002-02-21 18:17                           ` Hyman Rosen
2002-02-22  9:21                             ` Dmitry A. Kazakov
2002-02-22 16:59                               ` Hyman Rosen
2002-02-25  8:51                                 ` Dmitry A. Kazakov
2002-02-08 23:51       ` Merits of re-dispatching [LONG] Matthew Heaney
2002-02-12  9:02         ` Dmitry A. Kazakov
2002-02-07 23:40 ` Nick Roberts
2002-02-08  8:56   ` Dmitry A. Kazakov
2002-02-08  1:06 ` Matthew Heaney
2002-02-08  9:48   ` Dmitry A. Kazakov [this message]
2002-02-09  0:16     ` Matthew Heaney
2002-02-08 18:10   ` Hyman Rosen
2002-02-09  0:41     ` Matthew Heaney
2002-02-08 18:33 ` Nick Roberts
2002-02-09  4:07   ` Nick Roberts
2002-02-12 10:13   ` Dmitry A. Kazakov
2002-02-14 20:57 ` Tucker Taft
2002-02-15 15:43   ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox