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,68536605ede13a20 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.74.201 with SMTP id w9mr6400335pbv.0.1324513992370; Wed, 21 Dec 2011 16:33:12 -0800 (PST) MIME-Version: 1.0 Path: lh20ni49740pbb.0!nntp.google.com!news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!news.in2p3.fr!in2p3.fr!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!jacob-sparre.dk!ada-dk.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: GNAT - return by anonymous access Date: Wed, 21 Dec 2011 18:33:09 -0600 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: 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> <4ef1bd63$0$6567$9b4e6d93@newsspool4.arcor-online.net> <3a6fad50-c289-4300-bcc2-fb1f9f0b7e7a@l29g2000yqf.googlegroups.com> <4ef1cb93$0$7626$9b4e6d93@newsspool1.arcor-online.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1324513991 6448 69.95.181.76 (22 Dec 2011 00:33:11 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 22 Dec 2011 00:33:11 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Date: 2011-12-21T18:33:09-06:00 List-Id: "Georg Bauhaus" wrote in message news:4ef1cb93$0$7626$9b4e6d93@newsspool1.arcor-online.net... ... > OP wanted to return an allocated object of limited type (which > is when GNAT issues its message). If there is a reason for doing > so (maybe allocating a global library level task at some nested > level), then what can be done without a redesign? A redesign is necessary, because what he is trying to do is not likely to work on any Ada compiler, and is certainly not going to be portable to other Ada compilers (because the language rules aren't consistent). > (Is everyone happy with dropping return-by-reference for limited > types? There was a use case for these. I guess it has not > disappeared, whatever difficulties implementers might have > encountered...) We (the ARG) think that is you really need return-by-reference, you should write it explicitly using an access type. (And my preference is that access type is a pool-specific named access type, otherwise, you'll run into the sort of problems the OP did - the rules for anonymous types are a mess.) That is, your function should return an access value, not some other type where the by-reference nature is hidden (and causes all sort of problems in actual use). Ada 95's rules caused huge problems when you had limited types. In Claw, the registry key type is limited, and the effort to create the predefined keys was insane: you couldn't declare constants, you could declare a function, but you couldn't return an aggregate, you couldn't return a local object, you could return a global object -- but that is where we started! -- these objects couldn't be constants, they couldn't be initialized with an aggregate (either in the declaration or in the package body). We had to resort to initializing them component-by-component in the package body - a hugely error-prone way of working. Luckily, these things hardly ever change, so it was a one-time pain in Claw -- in other circumstances it could be a real maintenance problem. Ada 2005 added build-in-place to solve all of that. But for that to make sense, the old scheme had to go, thus we got rid of return-by-reference (which never made any sense in the first place). Randy.