Re: memory management and productivity
From: Robert I. Eachus (rieachus_at_comcast.net)
Date: 06/26/04
- Next message: Robert I. Eachus: "Re: memory management and productivity"
- Previous message: Robert I. Eachus: "Re: A simple ADA puzzle (I haven't the answer)"
- In reply to: Ole-Hjalmar Kristensen: "Re: memory management and productivity"
- Next in thread: Frank J. Lhota: "Re: memory management and productivity"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 26 Jun 2004 11:44:33 -0400
Ole-Hjalmar Kristensen wrote:
> Well, perhaps, but what Jano described is exactly like C++.
> Doesn't the automatic finalization of an access to a controlled
> object happen only when the *type* goes out of scope?
No, as Martin's program shows, finalization occurs when the object or
the type can no longer be referenced, no matter how that happens. This
means you have to be a bit careful in designing your Finalize procedure.
It may be called several times on the same object in complex cases.
(The rule is that controlled objects in Ada are always finalized at
least once. If you think about a subprogram that is doing clean-up when
an exception occurs, you can see why the choice is between at least once
and almost always.)
But writing Finalize so that it is okay to call it multiple times is
usually easy enough to do. Deallocating an object sets the pointer to
it to null, and doesn't complain if given a null pointer as an argument.
--
Robert I. Eachus
"Reason and experience both forbid us to expect that national morality
can prevail in exclusion of religious principles." -- George Washington
- Next message: Robert I. Eachus: "Re: memory management and productivity"
- Previous message: Robert I. Eachus: "Re: A simple ADA puzzle (I haven't the answer)"
- In reply to: Ole-Hjalmar Kristensen: "Re: memory management and productivity"
- Next in thread: Frank J. Lhota: "Re: memory management and productivity"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|