comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Ada2012 : Expression functions and extended return statements
Date: Fri, 6 Jan 2012 18:20:12 +0100
Date: 2012-01-06T18:20:12+01:00	[thread overview]
Message-ID: <1292hrynqxgnm$.12shf160d3gpi.dlg@40tude.net> (raw)
In-Reply-To: 1650969959347553100.869853martin-re.mo.ve.thedowies.com@news.btinternet.com

On Fri, 06 Jan 2012 08:45:22 -0600, Martin Dowie wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:

>> This is not a declaration, because the result is not an object.
> 
> 2012 RM 3.1 6/3 says it is a declaration (but I should have written
> 'Result' not 'Return').

Surely it says so, but it is not a declaration of the result object.

When the result is copy-out, it is another object which value could become
the value of the result object proper.

Even for limited types it is still not necessarily the result object. In
fact it is undecidable to figure out if it is:

   return X : Limited_T do
      if Halt (p) then
         raise I_Want_It_Otherwise;
      end if;
      ...
   end return;
exception
   when I_Want_It_Otherwise =>
      return Y : Limited_T do
          ...
      end return;

Who is the result object, X or Y?

The problem is that it is inherently inconsistent to have result objects
declared within the function body. What Ada actually does is no different
from a local variable, because there is no other way to return anything
from a subprogram. Why bother introducing awful syntax, which does not mean
what it is supposed to do?

> The evolution of Ada has always resulted in adding things that aren't
> "Ada-like" when compared to the previous revision.

Alas. Return statement is certainly not.

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



  parent reply	other threads:[~2012-01-06 17:20 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-06  8:45 Ada2012 : Expression functions and extended return statements Martin
2012-01-06  9:45 ` stefan-lucks
2012-01-06 10:02   ` Martin
2012-01-06 11:23     ` Peter C. Chapin
2012-01-06 11:37       ` Martin
2012-01-06 13:13         ` Dmitry A. Kazakov
2012-01-06 14:45           ` Martin Dowie
2012-01-06 15:07             ` Martin
2012-01-06 16:40             ` Robert A Duff
2012-01-06 17:04               ` Martin Dowie
2012-01-19  7:47               ` David Thompson
2012-01-06 17:20             ` Dmitry A. Kazakov [this message]
2012-01-07  1:47               ` Randy Brukardt
2012-01-07  9:21                 ` Dmitry A. Kazakov
2012-01-06 16:45           ` Adam Beneschan
2012-01-06 16:36     ` Adam Beneschan
2012-01-07 14:54     ` stefan-lucks
2012-01-07 15:11       ` Dmitry A. Kazakov
2012-01-08  9:41         ` stefan-lucks
2012-01-09  6:16         ` Randy Brukardt
2012-01-06 15:11   ` J-P. Rosen
2012-01-06 15:26     ` Martin
2012-01-07  1:50       ` Randy Brukardt
2012-01-07 10:12         ` Martin
2012-01-07 12:22           ` Simon Wright
2012-01-07 17:10             ` Martin
2012-01-09  6:21           ` Randy Brukardt
2012-01-09  7:57             ` Martin Dowie
2012-01-31 23:34             ` Yannick Duchêne (Hibou57)
2012-01-06 16:33 ` Adam Beneschan
2012-01-06 16:38   ` Adam Beneschan
2012-01-06 22:12     ` Robert A Duff
2012-01-31 23:20 ` 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