comp.lang.ada
 help / color / mirror / Atom feed
From: "Hibou57 (Yannick Duchêne)" <yannick_duchene@yahoo.fr>
Subject: Re: Dispatch on the result still does not work?
Date: Sat, 11 Jul 2009 06:36:48 -0700 (PDT)
Date: 2009-07-11T06:36:48-07:00	[thread overview]
Message-ID: <f4df2dac-81b6-4015-82a6-92926897071c@y17g2000yqn.googlegroups.com> (raw)
In-Reply-To: dyupu10xh14z.g4shiz3dk995.dlg@40tude.net

On 11 juil, 14:20, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
> Conceptually there is no any difference between parameters and results of a
> subprogram

IMHO, there is a difference. A result is something created, not
something assigned to. It is not like an out formal parameter, which
is intended to be use for an assignment.

Until the function creates the return value, the return value does not
exist. The result of the function may be may or may be not later
assigned to a variable, this matter it out of the function's
responsabilities.

Here is how it works with an out parameter:
+ an instance of a variable exists
+ a procedure is invoked giving it the instance of this variable as a
formal out parameter
+ the procedure assign something to an instance which already exists

Here is how it works with a function (conceptually):
+ the function is invoked
+ it creates a result
+ the returned created result is handled in various way by the calle

This is onceptually not the same.

Then if you have “ A := F (B); ”, for optimization purpose, the
compiler may implement it passing a reference to A to the function F,
and F may directly assign the result to the A reference, but this is
not the concept, this is a particular implementation.

Now, what if the function is invoked for a formal parameter which is,
let say “ Parameter : T'Class ” ? You view of the “ concept ” is no
more valid in this context (no more tagged value any more, unless you
expect to rely on a default for this formal parameter), and in any
way, the compiler will no more be able to apply the later optimization
exemple.

Conceptually, returning a result from a function, is not an
assignment, this is.... just returning a result from a function. If it
later turns into an assignment, this is a matter of the usage of the
function, not a matter of the work of the function. As a proof, this
happens only later, after the function was invoked, and more than
that, the result may not be assigned to any variable.

Have a nice time Dmitry



  reply	other threads:[~2009-07-11 13:36 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-11 10:04 Dispatch on the result still does not work? Dmitry A. Kazakov
2009-07-11 11:09 ` Chris Moore
2009-07-11 12:05   ` Dmitry A. Kazakov
2009-07-11 17:50     ` Chris Moore
2009-07-11 19:22       ` Dmitry A. Kazakov
2009-07-11 11:32 ` Hibou57 (Yannick Duchêne)
2009-07-11 12:20   ` Dmitry A. Kazakov
2009-07-11 13:36     ` Hibou57 (Yannick Duchêne) [this message]
2009-07-11 13:39       ` Hibou57 (Yannick Duchêne)
2009-07-11 15:19       ` Dmitry A. Kazakov
2009-07-11 18:08         ` Hibou57 (Yannick Duchêne)
2009-07-11 19:29           ` Dmitry A. Kazakov
2009-07-11 23:22             ` Hibou57 (Yannick Duchêne)
2009-07-12  9:46               ` Dmitry A. Kazakov
2009-07-11 18:54 ` Georg Bauhaus
2009-07-11 19:40   ` Dmitry A. Kazakov
2009-07-12 10:40     ` Chris Moore
2009-07-12 11:30       ` Dmitry A. Kazakov
2009-07-12 16:05         ` Chris Moore
2009-07-12 16:38           ` Dmitry A. Kazakov
2009-07-12 17:11             ` AdaMagica
2009-07-12 20:30               ` sjw
2009-07-13 16:55                 ` Adam Beneschan
2009-07-13 21:47                   ` sjw
2009-07-13 22:50                     ` Adam Beneschan
2009-07-14 21:06                       ` sjw
2009-07-13 15:13 ` Adam Beneschan
2009-07-13 15:17   ` Adam Beneschan
2009-07-13 16:33     ` AdaMagica
2009-07-13 18:46   ` Adam Beneschan
replies disabled

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