comp.lang.ada
 help / color / mirror / Atom feed
* Finalization of tagged types - problem
@ 2003-01-13  1:11 Victor Porton
  0 siblings, 0 replies; 4+ messages in thread
From: Victor Porton @ 2003-01-13  1:11 UTC (permalink / raw)


I have a non-limited tagged type (not derived from
Ada.Finalization.Controlled) Base.

I derive:

type State_Type is new Base with
   record
      -- ...
      Finalizer: Finalizer_Type(State_Type'Access);
   end record;

I want to add a component with back-reference derived
from Ada.Finalization.Controlled or
Ada.Finalization.Limited_Controlled for auto-finalization
of State_Type.

But

type Finalizer_Type(State: access State_Type) is
   new Ada.Finalization.Controlled with null record;
   
Compiler: "Access discriminant are allowed only for limited types".

Can be done something among the obvious but imperfect
solutions: 1. make Base controlled. 2. make Base limited
and derive Finalizer_Type from Limited_Controlled instead?



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

* Re: Finalization of tagged types - problem
@ 2003-01-13  8:21 Grein, Christoph
  2003-01-13 11:28 ` Victor Porton
  0 siblings, 1 reply; 4+ messages in thread
From: Grein, Christoph @ 2003-01-13  8:21 UTC (permalink / raw)


From: porton@ex-code.com (Victor Porton)

> I have a non-limited tagged type (not derived from
> Ada.Finalization.Controlled) Base.
> 
> I derive:
> 
> type State_Type is new Base with
>    record
>       -- ...
>       Finalizer: Finalizer_Type(State_Type'Access);
>    end record;
> 
> I want to add a component with back-reference derived
> from Ada.Finalization.Controlled or
> Ada.Finalization.Limited_Controlled for auto-finalization
> of State_Type.
> 
> But
> 
> type Finalizer_Type(State: access State_Type) is
>    new Ada.Finalization.Controlled with null record;
>    
> Compiler: "Access discriminant are allowed only for limited types".
> 
> Can be done something among the obvious but imperfect
> solutions: 1. make Base controlled. 2. make Base limited
> and derive Finalizer_Type from Limited_Controlled instead?

Victor,

I've published a few years ago in Ada Letters a paper "Add Finalization" dealing 
with this problem. You can find it online on my home page

<http://home.T-Online.de/home/Christ-Usch.Grein/Ada/Finalization.html>
                                                    ~~~~~~~~~~~~~~~~~
                                             Not exactly sure of this part
              If it fails, omit it and look for the title "Add Finalization"

HTH

Christoph



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

* Re: Finalization of tagged types - problem
  2003-01-13  8:21 Finalization of tagged types - problem Grein, Christoph
@ 2003-01-13 11:28 ` Victor Porton
  0 siblings, 0 replies; 4+ messages in thread
From: Victor Porton @ 2003-01-13 11:28 UTC (permalink / raw)


In article <mailman.1042446542.5578.comp.lang.ada@ada.eu.org>,
	"Grein, Christoph" <christoph.grein@eurocopter.com> writes:
> From: porton@ex-code.com (Victor Porton)
> 
>> I have a non-limited tagged type (not derived from
>> Ada.Finalization.Controlled) Base.
>> 
>> I derive:
>> 
>> type State_Type is new Base with
>>    record
>>       -- ...
>>       Finalizer: Finalizer_Type(State_Type'Access);
>>    end record;
>> 
>> I want to add a component with back-reference derived
>> from Ada.Finalization.Controlled or
>> Ada.Finalization.Limited_Controlled for auto-finalization
>> of State_Type.
>> 
>> But
>> 
>> type Finalizer_Type(State: access State_Type) is
>>    new Ada.Finalization.Controlled with null record;
>>    
>> Compiler: "Access discriminant are allowed only for limited types".
>> 
>> Can be done something among the obvious but imperfect
>> solutions: 1. make Base controlled. 2. make Base limited
>> and derive Finalizer_Type from Limited_Controlled instead?
> 
> I've published a few years ago in Ada Letters a paper "Add Finalization" dealing 
> with this problem. You can find it online on my home page
> 
> <http://home.T-Online.de/home/Christ-Usch.Grein/Ada/Finalization.html>

Christoph, thanks.

So is it your opinion: derive from Controlled if it may be needed
in a derived?

BTW, Is derivance from Controlled a big overhead?



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

* Re: Finalization of tagged types - problem
@ 2003-01-13 11:48 Grein, Christoph
  0 siblings, 0 replies; 4+ messages in thread
From: Grein, Christoph @ 2003-01-13 11:48 UTC (permalink / raw)


> > I've published a few years ago in Ada Letters a paper "Add Finalization" 
dealing 
> > with this problem. You can find it online on my home page
> > 
> > <http://home.T-Online.de/home/Christ-Usch.Grein/Ada/Finalization.html>
> 
> Christoph, thanks.

You're welcome.

> So is it your opinion: derive from Controlled if it may be needed
> in a derived?

No, it's not my opinion, it's a fact that you cannot add controlledness to 
unlimited types later without getting into an ocean of troubled water.

But I would not derive from Controlled just for suspense it might be needed 
later. When it turns out to be necessary, this is a design change, so you have 
to go back in any case and rethink the design.

> BTW, Is derivance from Controlled a big overhead?

Finalization causes the overhead because a queue of objects to be finalized has 
to be maintained for each scope.

Initialization and adjustment are cheap.

Also here, there's no free lunch.



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

end of thread, other threads:[~2003-01-13 11:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-13  8:21 Finalization of tagged types - problem Grein, Christoph
2003-01-13 11:28 ` Victor Porton
  -- strict thread matches above, loose matches on Subject: below --
2003-01-13 11:48 Grein, Christoph
2003-01-13  1:11 Victor Porton

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