comp.lang.ada
 help / color / mirror / Atom feed
From: Dmitry A. Kazakov <mailbox@dmitry-kazakov.de>
Subject: Type conversions on pool-specific access types
Date: Mon, 13 Oct 2003 12:34:41 +0200
Date: 2003-10-13T12:34:41+02:00	[thread overview]
Message-ID: <7kukov45dif9p7u2ohu6ml29mu9cgu621o@4ax.com> (raw)

Hi all!

Who knows any reason why conversions between pool-specific access
types are not allowed, provided that the storage pools are same? Isn't
storage pool statically known?

It is a real pain to use Unchecked_Conversion for:

type Base is new Ada.Limited_Controlled with ..;
type Base_Ptr is access Base'Class;
for Base_Ptr'Storage_Pool use ...;

procedure Foo (Object : Base_Ptr);
...
type Derived is new Base with ..;
type Derived_Ptr is access Derived'Class;
for Derived_Ptr'Storage_Pool use Base_Ptr'Storage_Pool;
...
declare
   Ptr : Derived_Ptr := new Derived;
begin
   Foo (Base_Ptr (Ptr)); -- ILLEGAL!

I do not understand why.

----------------
Another thing is initialization / finalization of controlled objects
allocated on some specific storage pool. It could be a great problem
if a pool-specific pointer is required:

type Base_Specific_Ptr is access Base;
for Base_Specific_Ptr'Storage_Pool use ...;
...
procedure Finalize (Object : in out Base) is
begin
   -- How to get a Base_Specific_Ptr to Object?
   -- We know that it is in the pool, but the compiler does not!

This requires general to pool-specific conversion. Which could
probably be non-portable, if Unchecked_Conversion is used to
Object'Unchecked_Access to Base_Specific_Ptr. (?)

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



             reply	other threads:[~2003-10-13 10:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-13 10:34 Dmitry A. Kazakov [this message]
2003-10-16  1:43 ` Type conversions on pool-specific access types Nick Roberts
2003-10-16 12:13   ` Dmitry A. Kazakov
2003-10-16 20:28     ` Nick Roberts
2003-10-17  4:27       ` Nick Roberts
2003-10-18  9:59       ` 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