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 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!newsfeed.freenet.de!news-lei1.dfn.de!news-ham1.dfn.de!news.uni-hamburg.de!cs.tu-berlin.de!uni-duisburg.de!not-for-mail From: Georg Bauhaus Newsgroups: comp.lang.ada Subject: Re: warning: cannot return a local value by reference Date: Wed, 2 Jun 2004 22:36:16 +0000 (UTC) Organization: GMUGHDU Message-ID: References: <40be5080$0$9181$626a14ce@news.free.fr> NNTP-Posting-Host: l1-hrz.uni-duisburg.de X-Trace: a1-hrz.uni-duisburg.de 1086215776 19292 134.91.1.34 (2 Jun 2004 22:36:16 GMT) X-Complaints-To: usenet@news.uni-duisburg.de NNTP-Posting-Date: Wed, 2 Jun 2004 22:36:16 +0000 (UTC) User-Agent: tin/1.5.8-20010221 ("Blue Water") (UNIX) (HP-UX/B.11.00 (9000/800)) Xref: g2news1.google.com comp.lang.ada:1040 Date: 2004-06-02T22:36:16+00:00 List-Id: 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