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.8 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!attcan!uunet!mcvax!enea!sommar From: sommar@enea.se (Erland Sommarskog) Newsgroups: comp.lang.ada Subject: Re: Garbage Collection Message-ID: <4222@enea.se> Date: 6 Jan 89 22:17:19 GMT Organization: ENEA DATA AB, Sweden List-Id: For the third time I asked Bill Wolfe how his idea with deallocation on block exit. With his last answer, I realized that due to unclarity from my side, he may have misunderstood my example. My apologies to you all, and Bill in particular. So I try again, and see if I can get it right: We have: Generic Data_type is limited private; with Assign, "<", ">" -- What you expect Package Binary_trees is Tree_type is private; Procedure Insert(Tree in out : Tree_type; Data : in Data_type); ... End Binary_trees; Package Use_trees is -- Could be a procedure. Could be generic. Type Any_type; -- Could also be generic parameter, or imported. Type Some_type; Type Some_access_type is access Some_type; Procedure Assign(A : in out Some_access_type; B : in Some_access_type) is Begin A := B End Assign; -- Also add "<" ">" to mean comparison on Any_type here. Package Tree_handler is new Binary_trees(Some_access_type, Assign); ... Procedure Put_something_in_tree(Tree : in out Tree_type; Anything : Any_type) is Reference : Some_access_type; Begin Reference := new Some_type; Do_something(Reference.all, Anything); Tree_handler.Insert(Tree, Reference); End; ... End Use_trees; Question: What happens with Reference.all when Put_something_in_tree is exited? I read your proposal as that it should be deallocated, which would be disastrous. Or is this a misunderstanding from my side? If it is not: is this code erroneous with your scheme? Side note: you said that the tree package should take a Destroy procedure. For what benefit? You can't automatically call it when your Destroy_tree is called. The caller might refer to the stored objects in some other place. Or does your Destroy_tree have a special parameter to control this? Seems like adding two parameters (one generic and one routine) that aren't necessary, but clutters up the user's code. The user can always traverse the tree and destroy what he has there. -- Erland Sommarskog ENEA Data, Stockholm This signature is not to be quoted. sommar@enea.se