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-Thread: 103376,74166d5f7afa0c82 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!newshub.sdsu.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Mon, 03 Jan 2005 17:09:47 -0600 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: Subject: Re: Return_By_Reference or Return_By_Copy (GNAT bug?) Date: Mon, 3 Jan 2005 17:11:24 -0600 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 Message-ID: NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-fP4zvY036mDIxuEtvxnM7gD5xznnhpSHA/buFnIvz26EF+W5kH6Yko5o6GAkR0nk8D3zSjguMZhl7Ee!hyxDIXi2ORmtF8oUyXSbjt+B/lg+kDTqeQFqFtPx13WuBmxq6XiZfQeIuVdJGjOqRiKfhN8jASor X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.22 Xref: g2news1.google.com comp.lang.ada:7417 Date: 2005-01-03T17:11:24-06:00 List-Id: "Duncan Sands" wrote in message news:mailman.21.1104616882.527.comp.lang.ada@ada-france.org... > I was playing around with return by reference to see if it is possible to > get unserialized access to a protected variable using the Rosen trick (it is, > see example below, especially the protected object P in package C). Will this > be illegal in Ada 2005? Yes, it will. ... ... > 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). -- Declare the function: function Get_The_A return access A_Type is begin return The_A'Access; -- to do this in Ada 2005. (Note this makes it explicit what you're doing - a good thing, IMHO.) > end; ... > package body C is > > protected body P is > > function Get_A return A_Type is > begin > return P_A; -- Similarly, this return will be illegal in Ada 2005. -- (Can't return an object from a limited function, as that would require a copy into the result object.) -- Use the same workaround as above. > end Get_A; > > end P; > > end; ...