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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,68536605ede13a20 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.68.191.41 with SMTP id gv9mr6384503pbc.5.1324513984604; Wed, 21 Dec 2011 16:33:04 -0800 (PST) Path: lh20ni49743pbb.0!nntp.google.com!news2.google.com!postnews.google.com!z19g2000vbe.googlegroups.com!not-for-mail From: Simon Belmont Newsgroups: comp.lang.ada Subject: Re: GNAT - return by anonymous access Date: Wed, 21 Dec 2011 16:33:04 -0800 (PST) Organization: http://groups.google.com Message-ID: <4f78ef9f-ca8d-43ef-ab71-0f775fbeebd9@z19g2000vbe.googlegroups.com> References: <784c67eb-a542-41b0-b23d-fca1234e56b2@n10g2000vbg.googlegroups.com> <95f3b0fc-af24-4ace-afc9-227e8893ea99@n6g2000vbg.googlegroups.com> <91845790-2447-4b2c-a6b5-1a52557c8c17@d10g2000vbk.googlegroups.com> NNTP-Posting-Host: 24.218.138.255 Mime-Version: 1.0 X-Trace: posting.google.com 1324513984 6283 127.0.0.1 (22 Dec 2011 00:33:04 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 22 Dec 2011 00:33:04 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: z19g2000vbe.googlegroups.com; posting-host=24.218.138.255; posting-account=ShYTIAoAAABytvcS76ZrG9GdaV-nXYKy User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: ARLUEHNKC X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; InfoPath.2),gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2011-12-21T16:33:04-08:00 List-Id: On Dec 21, 2:29=A0am, AdaMagica wrote: > Hm, no, return-by-reference has been replaced by build-in-place. Building in place creates another object, does it not? Changes to a returned built in place type would not affect the original object. Suppose I have a package with some internal object of a limited, not necessarily allocated, but that has to get exposed to other units: package body Sample is foo : Lim_Type_Ptr :=3D -- ...stuff function Get return Lim_Type is begin return foo.all; end Sample; The above code, which as I understand it would be legal Ada95 code, doesn't return the actual object, but returns a pointer that the compiler automatically dereferences behind the scenes. The client can't change, copy, or delete the object or the access value because it cannot reference it. In the Ada05 version, it would have to return a Lim_Type_Ptr (or, equivilently, an access Lim_Type), and the client would have to dereference it. Now the client has free means to change, copy, and deallocate the access value. At best it works the same, and at worst an errant programmer can wreak havoc. I suppose my question is why? No one seems to have a valid technical reason for this change, other than returning-by-reference is 'unusual', which doesn't seem like nearly enough of a good reason to take something that was working fine and make it more dangerous. -sb