comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Return_By_Reference or Return_By_Copy (GNAT bug?)
Date: Tue, 4 Jan 2005 17:27:09 -0600
Date: 2005-01-04T17:27:09-06:00	[thread overview]
Message-ID: <HeydnRk3xLJtuEbcRVn-og@megapath.net> (raw)
In-Reply-To: $xgF7TJy$z4V@eisner.encompasserve.org

"Larry Kilgallen" <Kilgallen@SpamCop.net> wrote in message
news:$xgF7TJy$z4V@eisner.encompasserve.org...
> >> package body B is
> >>
> >>    The_A : A_Type;
> >>
> >>    function Get_The_A return A_Type is
> >>    begin
> >>       return The_A;
> >
> > -- This return will be illegal in Ada 2005 (the return expression is not
an
> > aggregate or function call).
>
> Even though nothing in that sample says protected ?

It's nothing to do with protected; the rules for all functions returning
*limited* types have changed. (Both to make constructor functions possible,
and to make limited interfaces be near universal.) The incompatibility is
fairly rare (such functions are rarely useful in Ada 95), and the workaround
is easy -- with one possible exception: functions returning limited private
types. (Those seem more common.) Note, however, that such a function, while
legal in Ada 95, probably would raise Program_Error if instantiated with a
really limited type. So we're just making a run-time problem into a
compile-time one: that is, detecting an error earlier.

                            Randy.






  reply	other threads:[~2005-01-04 23:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-31 11:07 Return_By_Reference or Return_By_Copy (GNAT bug?) Duncan Sands
2004-12-31 21:32 ` Randy Brukardt
2005-01-01 22:00   ` Duncan Sands
2005-01-03 23:11     ` Randy Brukardt
2005-01-04  4:20       ` Larry Kilgallen
2005-01-04 23:27         ` Randy Brukardt [this message]
2005-01-08 13:06       ` Duncan Sands
2005-01-10 21:05         ` Randy Brukardt
2005-03-08 16:12           ` Duncan Sands
replies disabled

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