comp.lang.ada
 help / color / mirror / Atom feed
From: Brian Drummond <brian_drummond@btconnect.com>
Subject: Re: smart pointer dangerous (no -> operator)
Date: Sat, 17 Jan 2009 00:43:17 +0000
Date: 2009-01-17T00:43:17+00:00	[thread overview]
Message-ID: <6j22n4ll4932l07nqc1c8d5q5rubrj9c3a@4ax.com> (raw)
In-Reply-To: a8go9gb0a60q.wypnft0gfg98$.dlg@40tude.net

On Fri, 16 Jan 2009 12:09:16 +0100, "Dmitry A. Kazakov"
<mailbox@dmitry-kazakov.de> wrote:

>1. In Ada 95 I declare the proxy type tagged controlled. The handle is
>created through a instantiation in the private part of the generic package
>Handle:
>
>   type X_Handle is new Ada.Finalization.Controlled with private;
>      -- Repeat all operations of the target
>   procedure Foo (Object : X_Handle);
>   ... -- and so on
>private
>   package Handles is not Object.Handle (...); -- Instantiation
>   type X_Handle is new Handles.Handle with null record;
>
>The implementation of Foo goes as follows:
>
>   procedure Foo (Object : X_Handle) is
>   begin
>       Foo (Ptr (Object).all);
>   end Foo;
>
>this is extremely tedious, but the best way I know.

As an Ada newbie, I've probably lost track of something important, but
I can't see a reason not to create a generic procedure, and simply
instantiate it for each Foo, which would be slightly less boring if it
worked..

I suspect it can't be that simple, but I can't see why. You don't know
the type of Ptr (Object).all but can't it be private from the generic's
point of view, or is that where a generic falls apart? Whatever the
type, there must be a Foo() for it, or the above wouldn't compile.

-Brian




  parent reply	other threads:[~2009-01-17  0:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-16 10:04 smart pointer dangerous (no -> operator) Oliver Kowalke
2009-01-16 11:09 ` Dmitry A. Kazakov
2009-01-16 11:42   ` Georg Bauhaus
2009-01-16 12:43     ` Dmitry A. Kazakov
2009-01-16 21:21     ` Maciej Sobczak
2009-01-17 19:07       ` Georg Bauhaus
2009-01-16 11:46   ` Oliver Kowalke
2009-01-16 12:45     ` Dmitry A. Kazakov
2009-01-17  0:43   ` Brian Drummond [this message]
2009-01-17  9:28     ` Dmitry A. Kazakov
2009-01-16 20:08 ` Tero Koskinen
2009-01-16 21:16   ` Maciej Sobczak
2009-01-18 12:21 ` Samuel Tardieu
replies disabled

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