comp.lang.ada
 help / color / mirror / Atom feed
* deallocating class wide types
@ 2003-05-10 12:02 alfonso acosta
  2003-05-10 12:11 ` alfonso acosta
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: alfonso acosta @ 2003-05-10 12:02 UTC (permalink / 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




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

end of thread, other threads:[~2003-05-12  0:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-10 12:02 deallocating class wide types alfonso acosta
2003-05-10 12:11 ` alfonso acosta
2003-05-10 12:41 ` David C. Hoos
2003-05-12  0:12 ` Robert I. Eachus

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