comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <sb463ba@l1-hrz.uni-duisburg.de>
Subject: Re: warning: cannot return a local value by reference
Date: Wed, 2 Jun 2004 22:36:16 +0000 (UTC)
Date: 2004-06-02T22:36:16+00:00	[thread overview]
Message-ID: <c9lkp0$iqs$1@a1-hrz.uni-duisburg.de> (raw)
In-Reply-To: 40be5080$0$9181$626a14ce@news.free.fr

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:36 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 [this message]
2004-06-02 22:49   ` k_leau
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