From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: How to declare a generic formal type "covered" by another?
Date: Fri, 2 May 2014 17:33:45 +0200
Date: 2014-05-02T17:33:45+02:00 [thread overview]
Message-ID: <1dnxemiiras21.1p85n74xnxy38.dlg@40tude.net> (raw)
In-Reply-To: lk0ck1$449$1@dont-email.me
On Fri, 02 May 2014 08:12:01 -0700, Jeffrey Carter wrote:
> One can create a safe-pointer package that does not expose an access type (see
> the PragmAda Reusable Components for an example), but the result tends to be
> restricted to pointers to definite, non-limited types.
Safe-pointers do make much sense only with definite and non-limited types.
I pass the pointer type to the package of safe pointers. It also gives an
opportunity to have it pool-specific, when necessary. Yes, the object is
allocated on the client side, e.g.
Handle.Set (new Object (...constraints...)); -- [*]
with Ada 2005 one could hide passed type returning anonymous access and
using limited return constructing function. Though, as experience shows, it
does not work well, especially the latter.
----
* This is a simplification, of course. If the object cannot be fully
initialized per Initialize. It looks like:
declare
Ptr : Object_Ptr := new Object (...);
Thing : Object'Class renames Ptr.all;
begin
Handle.Set (Ptr);
... -- Initialize Thing
end;
I wished Ada had a syntax to access allocated objects through class-wide
pointers. Something like:
... new X : Object (...) ... do
-- In this scope X refers to the allocated Object
end new;
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2014-05-02 15:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-01 6:54 How to declare a generic formal type "covered" by another? Natasha Kerensikova
2014-05-01 7:09 ` J-P. Rosen
2014-05-01 7:33 ` Natasha Kerensikova
2014-05-01 13:35 ` J-P. Rosen
2014-05-01 17:56 ` Natasha Kerensikova
2014-05-01 20:59 ` Jeffrey Carter
2014-05-02 7:58 ` AdaMagica
2014-05-02 8:17 ` Natasha Kerensikova
2014-05-02 15:12 ` Jeffrey Carter
2014-05-02 15:33 ` Dmitry A. Kazakov [this message]
2014-05-02 16:00 ` AdaMagica
2014-05-01 9:30 ` Georg Bauhaus
2014-05-01 9:32 ` Georg Bauhaus
2014-05-01 9:33 ` Georg Bauhaus
2014-05-01 16:34 ` Georg Bauhaus
2014-05-01 18:11 ` Natasha Kerensikova
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox