From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,74b55538385b7366 X-Google-Attributes: gid103376,public From: "Vladimir Olensky" Subject: Re: Which is right here - GNAT or OA ? Date: 1999/05/31 Message-ID: <928136551.707.11@news.remarQ.com>#1/1 X-Deja-AN: 483991383 References: <928083159.436.79@news.remarQ.com> <7is6pt$8cd$1@nnrp1.deja.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 X-Complaints-To: newsabuse@remarQ.com X-Trace: 928136551.707.11 K3TLTKYJOA5C9C7F8C qube-01.us-ca.remarq.com Organization: Posted via RemarQ Communities, Inc. NNTP-Posting-Date: Mon, 31 May 1999 07:42:31 GMT Newsgroups: comp.lang.ada Date: 1999-05-31T00:00:00+00:00 List-Id: Robert Dewar wrote in message <7is6pt$8cd$1@nnrp1.deja.com>... >In article <928083159.436.79@news.remarQ.com>, > "Vladimir Olensky" wrote: > >Note that you have to be careful in the ase of controlled >objects not to try to free statically allocated stuff. This >is a user responsibility in writing the Finalize routine! > That's right and the very purpose of this small example (one among some others) was to to illustrate why it is necessary distinguish between statically allocated and dynamically allocated objects when using controlled types for user defined automatic objects deallocation (GB) to provide proper program behavior. I doing this in other examples and this one is explaining why it is necessary. I mentioned that I am doing such checks few months ago in the thread related to Garbage Collection that arise from time to time here. At that time I was wondering if it possible for compiler itself to provide some additional compile time info so that RTS could perform such check later without necessity to do it manually. I still think that it is possible and that this is one of the necessary steps on the way of implementing full featured GB. Even without system GB it can make life easier for programmers. As I mentioned I did this stuff long time ago and now I want to put some pieces of code to Adapower as "touch and feel" ready to use examples of using controlled types. "Touch and feel" is one the best ways to explain things. Someone who wants to know can try "touch and feel" example see the output read short explanations end comments and as a result he/she will have internal feeling related to that subject. >So this programs is erroneous, and given that, OA and >GNAT behave identically, namely they give unpredictable >results. As I explained in the first message and in here above it erroneous on purpose. It helps to explain why one should check if the variable is static prior to attempt do deallocate it doing finalization (what is being done in my other examples related to use of controlled types) . I only thought that both GNAT and OA will raise exception at the same Statement_1. OA is raising exception at -- Statement_1: ( free(q_ptr)); but GNAT performing it without any complains and after that pointer to that record get NULL value but object continue to exists. So at -- Statement_2: Put( (q1.ID),2) GNAT is extracting field from the record and printing it without no problems. Statement_3 was to show that when q_ptr has NULL value exception should be raised here. ------------------- Regards, Vladimir Ylensky