From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,da8fecd51414cd54 X-Google-Attributes: gid103376,public Path: g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!nnx.oleane.net!oleane!in2p3.fr!proxad.net!feeder2-1.proxad.net!news9-e.free.fr!not-for-mail From: "k_leau" Newsgroups: comp.lang.ada References: <40be5080$0$9181$626a14ce@news.free.fr> Subject: Re: warning: cannot return a local value by reference Date: Thu, 3 Jun 2004 00:49:59 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Message-ID: <40be599b$0$9178$626a14ce@news.free.fr> Organization: Guest of ProXad - France NNTP-Posting-Date: 03 Jun 2004 00:50:05 MEST NNTP-Posting-Host: 81.56.189.156 X-Trace: 1086216605 news9-e.free.fr 9178 81.56.189.156:4496 X-Complaints-To: abuse@proxad.net Xref: g2news1.google.com comp.lang.ada:1041 Date: 2004-06-03T00:50:05+02:00 List-Id: Thanks "Georg Bauhaus" wrote in message news:c9lkp0$iqs$1@a1-hrz.uni-duisburg.de... > k_leau 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