From: alfonso acosta <alfonso_acosta_mail@yahoo.es>
Subject: deallocating class wide types
Date: Sat, 10 May 2003 14:02:09 +0200
Date: 2003-05-10T14:02:09+02:00 [thread overview]
Message-ID: <3ebcea42$1_4@news.arrakis.es> (raw)
hi:
I provide a simplified example of my problem:
package spec:
----------------------------------------------------------------
package My_Class is
type My_Class is abstract tagged null record;
type My_Class_Access is access all My_Class'Class;
procedure Destroy (Object: in out My_Class_Access);
end My_Class;
----------------------------------------------------------------
first body approach:
----------------------------------------------------------------
with Ada.Unchecked_Deallocation;
package body My_Class is
procedure Free is
new Ada.Unchecked_Deallocation(Name => My_Class_Access,
Object => My_Class'Class);
procedure Destroy (Object: in out My_Class_Access) renames Free;
end My_Class;
----------------------------------------------------------------
I get:
my_class.adb:7:59: subprogram used in renaming_as_body cannot be intrinsic
second approach:
----------------------------------------------------------------
with Ada.Unchecked_Deallocation;
package body My_Class is
procedure Free is
new Ada.Unchecked_Deallocation(Name => My_Class_Access,
Object => My_Class'Class);
procedure Destroy (Object: in out My_Class_Access) is
begin
Free(My_Class_Access);
end Destroy;
end My_Class;
------------------------------------------------------------------
I get:
my_class.adb:9:09: Invalid use of subtype mark in expression or call
Can someone tell me what Im doing wrong?
And, should Destroy work with any type which extends My_Class?
Thanks in advance:
Alfonso Acosta
next reply other threads:[~2003-05-10 12:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-10 12:02 alfonso acosta [this message]
2003-05-10 12:11 ` deallocating class wide types alfonso acosta
2003-05-10 12:41 ` David C. Hoos
2003-05-12 0:12 ` Robert I. Eachus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox