comp.lang.ada
 help / color / mirror / Atom feed
* Type conversions on pool-specific access types
@ 2003-10-13 10:34 Dmitry A. Kazakov
  2003-10-16  1:43 ` Nick Roberts
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry A. Kazakov @ 2003-10-13 10:34 UTC (permalink / 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



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-10-18  9:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-13 10:34 Type conversions on pool-specific access types Dmitry A. Kazakov
2003-10-16  1:43 ` 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

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