From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Overring function and its returned type
Date: Mon, 19 Nov 2012 16:19:49 +0100
Date: 2012-11-19T16:19:49+01:00 [thread overview]
Message-ID: <104675gvcsndz.1v2aaipa7277i$.dlg@40tude.net> (raw)
In-Reply-To: 687a06e4-3545-444d-9fbe-4e2e5f7055f2@googlegroups.com
On Mon, 19 Nov 2012 05:04:25 -0800 (PST), AdaMagica wrote:
> On Monday, November 19, 2012 9:41:07 AM UTC+1, Hibou57 (Yannick Duch�ne) wrote:
>>> How can this be? The actual of an out-parameter exists already, whereas
>>> the return object is newly created.
>>
>> He meant it, semantically. You can return a value into an already existing
>> object, and in practice, except with purely functional languages, that's
>> always how it goes (even if the target may be adjusted in some way for
>> many reasons).
>
> From this point of view, they are semantically the same in Ada. But for me, it's a non sequitur.
>
> An out parameter as an update is like an assignment A := B; hidden inside
> some procedure; a return object is constructed somehow.
Even if the target already exists?
Out parameters cannot be used together with assignment but I would not
consider it a semantic difference. It is a syntactic artefact IMO.
> This is fundamentally different for me.
>
> Is (1) equal to (2):
> declare
> A: T := Some_Value; -- (1)
> begin
> A := Some_Value; -- (2)
But function result is definitely not initialization, if you meant that. So
1 and 2 are exactly same, except for semantically broken limited returns,
of course.
Furthermore, starting with Ada 2005 which borrowed FORTRAN's idea of named
result you could have the result constructed inside a function:
return Result : T do
-- It is constructed here
end return;
You could even have it constructed and destructed more than once!
(unfortunately)
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2012-11-22 3:25 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-09 7:13 Overring function and its returned type Yannick Duchêne (Hibou57)
2012-11-09 7:22 ` Yannick Duchêne (Hibou57)
2012-11-09 8:24 ` Dmitry A. Kazakov
2012-11-09 9:14 ` Yannick Duchêne (Hibou57)
2012-11-09 13:11 ` Dmitry A. Kazakov
2012-11-09 21:36 ` Yannick Duchêne (Hibou57)
2012-11-09 19:24 ` Adam Beneschan
2012-11-09 19:34 ` Adam Beneschan
2012-11-09 22:00 ` J-P. Rosen
2012-11-09 22:30 ` Yannick Duchêne (Hibou57)
2012-11-09 19:57 ` sbelmont700
2012-11-09 21:10 ` Yannick Duchêne (Hibou57)
2012-11-09 21:56 ` sbelmont700
2012-11-10 0:28 ` Yannick Duchêne (Hibou57)
2012-11-10 2:35 ` Yannick Duchêne (Hibou57)
2012-11-15 15:13 ` Peter C. Chapin
2012-11-16 10:40 ` Maciej Sobczak
2012-11-16 12:39 ` Peter C. Chapin
2012-11-16 15:27 ` Maciej Sobczak
2012-11-16 17:29 ` Peter C. Chapin
2012-11-17 4:16 ` Yannick Duchêne (Hibou57)
2012-11-17 19:11 ` Robert A Duff
2012-11-18 14:53 ` AdaMagica
2012-11-19 8:41 ` Yannick Duchêne (Hibou57)
2012-11-19 13:04 ` AdaMagica
2012-11-19 15:19 ` Dmitry A. Kazakov [this message]
2012-11-19 23:42 ` Randy Brukardt
2012-11-10 7:55 ` Randy Brukardt
2012-11-11 1:02 ` Yannick Duchêne (Hibou57)
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox