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=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!husc6!purdue!rjh From: rjh@cs.purdue.edu (Bob Hathaway) Newsgroups: comp.lang.ada Subject: Re: Garbage Collection Message-ID: <5696@medusa.cs.purdue.edu> Date: 27 Dec 88 22:24:22 GMT References: <4195@enea.se> Sender: news@cs.purdue.EDU Reply-To: rjh@cs.purdue.edu (Bob Hathaway) Organization: Department of Computer Science, Purdue University List-Id: >According to Bill the data allocated to Reference should be freed when >we exit this procedure, but if Insert does what we think this is of >course a severe error. Where did I go wrong? Did I plead guilty to I think Bill meant deallocation should only occur if an object is no longer accessible at the end of a subprogram or block, and Reference is accessible. Subprogram and block exit is a very convenient time to perform clean-up of access types. If Ada had an Adt construct for the "completion of the Adt paradigm", we could specify a termination procedure for Adts which could also be called at scope exit. I agree that Adts/objects are an important enough programming development to justify a new language construct. I've worked with over 200,000 lines of code which used the older data-structure oriented design and found the greatest problem in understanding and working with these programs was caused by the use of global variables and the indescriminant access and modification of data-structures which were not implemented as Adts. Such data-structures are poorly defined and lead to code which is hard to read. For my own opinion on the garbage collection discussion, I think a destroy procedure is desirable. Adts need to be explicitly deallocated for long running daemons or loops even while objects are still accessible. While calling a procedure or declaring objects in a local block from within a loop allows automatic deallocation of objects, I'd rather use scope rules and subprograms for creating environments and performing actions and not for storage (de)allocation. Also, I think Adt operations should include a destroy procedure for completeness. If space management is not a problem the destroy procedure does not have to be called. Concerning working sets, if a page is not accessed it will not reside in memory for long and should not cause a virtual space management problem. I strongly agree with assignment operator overloading, and another powerful extension is to allow any name/operator to be overloadable. For yet another Ada 9X extension, I propose procedural variables. As in Modula procedural variables can be limited to top level procedures but formal parameter names must be included for named parameter association. Here is an example declaration: type insertNode_procedure = procedure (adt : in out structure, node : in node); Variables of type insertNode_procedure can be assigned to any procedure with the same parameter type structure (type domain). Procedural variables can avoid the redundant use of case statements by allowing an operation to be stored within an Adt. It also allows individually parameterizable and reprogrammable Adts since operations can be provided to alter the Adts actions or structure. Generic subprogram parameters can only allow Adts to be set once for any instantiation. I use procedural variables and function pointers in Adts frequently when programming in languages other than Ada and am convinced they are an elegant way to model Adt actions. Bob Hathaway rjh@purdue.edu