comp.lang.ada
 help / color / mirror / Atom feed
From: "k_leau" <k_leau@yahoo.com>
Subject: Re: warning: cannot return a local value by reference
Date: Thu, 3 Jun 2004 00:49:59 +0200
Date: 2004-06-03T00:50:05+02:00	[thread overview]
Message-ID: <40be599b$0$9178$626a14ce@news.free.fr> (raw)
In-Reply-To: c9lkp0$iqs$1@a1-hrz.uni-duisburg.de

Thanks

"Georg Bauhaus" <sb463ba@l1-hrz.uni-duisburg.de> wrote in message
news:c9lkp0$iqs$1@a1-hrz.uni-duisburg.de...
> k_leau <k_leau@yahoo.com> wrote:
> : Hello,
> :
> : I am new to Ada programming and I have the following problem:
>
> The value of type item_dbm that your function should return is
>
> a) local to the function
> b) limited.
>
> (b) makes item_dbm a return-by-reference type under current rules.
> (The local value will be lost when the function is done, it can
> no longer be refered to).
>
> Instead you could declare a procedure,
>
>   procedure new_from_old(old: item_dbm; another: out item_dbm);
>
> and then create a new item_db object, `fresh', and initialise it with
> values from a previous item_db object,
>
>   declare
>      fresh: item_dbm;
>   begin
>      new_from_old(..., fresh);
>      ...use fresh...
>   end;
>
>
>
> -- Georg




  reply	other threads:[~2004-06-02 22:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-02 22:11 warning: cannot return a local value by reference k_leau
2004-06-02 22:36 ` Georg Bauhaus
2004-06-02 22:49   ` k_leau [this message]
2004-06-03  8:23 ` Martin Krischik
2004-06-03 10:02   ` k_leau
2004-06-03 10:37     ` Martin Krischik
replies disabled

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