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.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Why is the destructor called multiple times after I declare an object? Date: Thu, 14 Jan 2016 14:42:53 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <293c58ac-4ebd-488a-abcc-b6e88811eec8@googlegroups.com> <871t9ogevj.fsf@theworld.com> NNTP-Posting-Host: bqgfK7NL3xTHnr0WRaLl4g.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:29128 Date: 2016-01-14T14:42:53+01:00 List-Id: On 14/01/2016 11:04, Georg Bauhaus wrote: > On 13.01.16 20:59, Dmitry A. Kazakov wrote: >> Sure, some object is always returned and every object is always same >> to itself. This is not sufficient to define useful "in-place". In my >> view a definition must have the place known at the caller's context. >> E.g. to have the object: >> >> 1. Allocated at a specific machine address >> 2. Allocated by an allocator in the specific memory pool >> 3. Allocated as a specific component of a container object >> 4. Allocated as a parent of a derived type object >> >> The problem of returned object is that it conflates allocation with >> initialization. > > If Ada will have a way for the caller to express the placement of new > objects to be constructed in situ by functions, By procedures, of course. Initializer must a procedure. > might we then go back to just > return-by-reference in the hope of abandoning "return-by-access"? There is a simpler and cleaner way. What is needed is user-defined procedures implementing record/array component read and update access as primitive operations. No need to implement the syntax sugar X.M := F (...) literally as two separate evaluations of X.M and F(...) with inventing some intermediate objects to pass to some virtual assignment meaningless for limited types anyway. It should be Set_M (X, ...); with lots of problems with limited and indefinite types eliminated. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de