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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!.POSTED!not-for-mail From: Georg Bauhaus Newsgroups: comp.lang.ada Subject: Re: Why is the destructor called multiple times after I declare an object? Date: Thu, 14 Jan 2016 11:04:28 +0100 Organization: A noiseless patient Spider Message-ID: References: <293c58ac-4ebd-488a-abcc-b6e88811eec8@googlegroups.com> <871t9ogevj.fsf@theworld.com> Reply-To: nonlegitur@futureapps.de Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 14 Jan 2016 10:01:47 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="b96887e80893c84a90c3007226ca0d1c"; logging-data="13324"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/XhZsrdf5O2GeM+2wbDu+ULpyzNTudBQQ=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 In-Reply-To: Cancel-Lock: sha1:s9sFm54kKBwpQh9XIAl2u5osfHw= Xref: news.eternal-september.org comp.lang.ada:29125 Date: 2016-01-14T11:04:28+01:00 List-Id: 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, might we then go back to just return-by-reference in the hope of abandoning "return-by-access"? I.e., in this case, the caller could request that a limited object be placed, e.g., on the stack, after having been initialized by the function. Or that it become a named component of some other object. -- "HOTDOGS ARE NOT BOOKMARKS" Springfield Elementary teaching staff