TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Christoph & Ursula Grein <[log in to unmask]>
Wed, 16 Jul 1997 21:01:00 +0100
text/plain (50 lines)
At 7/11/97 Robert Eachus answered:

>   Again, as I said, this is highly platform dependent, but...
>
>   Finalization of the RHS occurs after assignment (and adjusting).  The
>LHS is of course finalized before the assignment and components of an
>object are finalized before the entire object...

OK, I did not think of such things, instead I was talking about the following:

  Deep_Inner_Level:
  declare
    X: Controlled;
  begin
    ...
  end Deep_Inner_Level;  -- X is finalized here, no Adjust!

Now suppose this happens in a real-time system in a cyclic task.
Any stack will soon overflow...

For this to work properly, I used 'Unchecked_Access:

  type Controlled is new Uncontrolled with record
    Controller: Component := (Ada.Finalization.Controlled with
                              Controlled'Unchecked_Access);
  end record;

Within package Add_Finalization, this is absolutely safe. The simple
'Access would raise Constraint_Error.

The rest of your explanation, Robert, was rather specific to your solution of
the problem (which however you did not show - you *did* show the rather simple
case for limited types) and is still not very clear to me - and I suppose
neither to the rest of us.
By the way, the problem's originator Heath White ([log in to unmask]) is
amazingly reticent...

I do not want to badger you into it, but I think it would make the discussion
much simpler if you let the cat out of the bag... (Some more animals?)

>...then Adjust comes along and can do its thing knowing the contents of the
>"old" value.  If a Finalize doesn't have a corresponding Adjust, which in my
>program only occured at program termination, no big deal.

But I think a big deal in the above case!

So for now thankU for the lively discussion.

Christoph Grein

ATOM RSS1 RSS2