comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Why is the destructor called multiple times after I declare an object?
Date: Thu, 14 Jan 2016 10:47:11 +0100
Date: 2016-01-14T10:47:11+01:00	[thread overview]
Message-ID: <n77qrk$22b$1@gioia.aioe.org> (raw)
In-Reply-To: n77o66$1e2$1@dont-email.me

On 14/01/2016 10:04, J-P. Rosen wrote:
> Le 13/01/2016 21:09, Dmitry A. Kazakov a écrit :
>>> OK, let's state it differently. The called function builds its result
>>> "somewhere". That "somewhere" is what will be used by the caller as the
>>> variable being initialized.
>>
>> A non-limited result is built "somewhere", just the same. I think
>> in-place must be a definite place, not just "somewhere".
> In the non-limited case, copying is allowed (although not required), so
> there is no issue. What I mean is that it can work the other way round
> from your mental model: you think of the caller allocating the result
> space, and the function using that space; but it can be the function
> that choses where to build the result, and then the caller using that
> space for the object. It may not be the usual stack model, but that's
> irrelevant (we already know that a secondary stack may be used in some
> cases).

For many (most, actually) important cases this is relevant, e.g. for an 
initialized limited component of a container object or a parent of. 
There is no way to do this without exposing all innards and even with 
exposing them chances are very high it won't work anyway.

>>> It is perfectly OK if the function starts building the result in
>>> "somewhere_1", then decides to switch to "somewhere_2", as long as the
>>> eventual "somewhere" is what is used by the caller, /without copy/.
>>
>> "Without copy" requires a definition too. IMO, it must mean that no type
>> operations are called otherwise than on the final result (function
>> arguments do not count). For example, Initialize must be called strictly
>> once.
> "Without copy" means that the value constructed and returned by the
> function should not be moved to a different memory  location.
> What else?

You mean "object constructed" (the object refers to a value). I think 
that "copy" should be stated in terms of operations defined on the 
object. If the client cannot tell difference through legal operation 
then it is OK. Therefore the requirement that Initialize and other 
elaboration stuff must be performed once.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  reply	other threads:[~2016-01-14  9:47 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-11  1:37 Why is the destructor called multiple times after I declare an object? Andrew Shvets
2016-01-11  2:18 ` Jeffrey R. Carter
2016-01-11  3:35   ` Andrew Shvets
2016-01-11 17:02     ` Brian Drummond
2016-01-11 16:29   ` Brian Drummond
2016-01-11 17:20     ` Simon Wright
2016-01-11 18:17     ` Bob Duff
2016-01-11 21:10       ` Dmitry A. Kazakov
2016-01-11 23:44         ` Randy Brukardt
2016-01-12  9:33           ` Dmitry A. Kazakov
2016-01-12 20:21             ` Randy Brukardt
2016-01-12 21:05               ` Dmitry A. Kazakov
2016-01-13  0:02                 ` Robert A Duff
2016-01-13  8:31                   ` Dmitry A. Kazakov
2016-01-13  9:01                     ` Georg Bauhaus
2016-01-13 14:45                     ` J-P. Rosen
2016-01-13 20:09                       ` Dmitry A. Kazakov
2016-01-14  9:04                         ` J-P. Rosen
2016-01-14  9:47                           ` Dmitry A. Kazakov [this message]
2016-01-13 16:03                     ` Robert A Duff
2016-01-13 19:59                       ` Dmitry A. Kazakov
2016-01-14 10:04                         ` Georg Bauhaus
2016-01-14 13:42                           ` Dmitry A. Kazakov
2016-01-12 12:41       ` Brian Drummond
2016-01-13 20:18       ` Jacob Sparre Andersen
2016-01-14  1:31         ` Robert A Duff
2016-01-12  0:43     ` Jeffrey R. Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox