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-Received: by 2002:a6b:9057:: with SMTP id s84-v6mr13863428iod.27.1539619547966; Mon, 15 Oct 2018 09:05:47 -0700 (PDT) X-Received: by 2002:a9d:3f09:: with SMTP id m9mr303232otc.5.1539619547861; Mon, 15 Oct 2018 09:05:47 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!goblin1!goblin.stu.neva.ru!z5-v6no49951ite.0!news-out.google.com!n199-v6ni60itn.0!nntp.google.com!z5-v6no49947ite.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 15 Oct 2018 09:05:47 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=149.32.224.35; posting-account=Qh2kiQoAAADpCLlhT_KTYoGO8dU3n4I6 NNTP-Posting-Host: 149.32.224.35 References: <82fdea5d-b9b6-4f1e-a45f-ee0ff9f55946@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <436802a9-a7ee-4ce0-9f16-948f1b3a3441@googlegroups.com> Subject: Re: In mode parameter in an assignment statement From: Anh Vo Injection-Date: Mon, 15 Oct 2018 16:05:47 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:54593 Date: 2018-10-15T09:05:47-07:00 List-Id: On Saturday, October 13, 2018 at 1:38:03 AM UTC-7, Jeffrey R. Carter wrote: > On 10/13/2018 02:48 AM, Anh Vo wrote: > > > > I thought it should be rejected during compilation because in mode parameter is not allowed in an assignment statement. But, it was compiled successfully under GNAT obviously. > > > > What did I miss? Thanks in advance. > > Others have pointed out that the in-mode parameter, Region, is of an access > type. What may not be clear is why this makes a difference. It's important to > distinguish the access value (stored in Region) from its designated value > (Region.all). The access value is constant within the procedure; any attempt to > change it > > Region := new Mapped_Region_Record; > > would result in a compiler error. However, the access value is the only thing > that is an in-mode parameter and constant within the procedure. The designated > value, Region.all, is not constant and may be modified. That is what's happening > in the procedure. That Ada access types allow for implicit dereference and can > usually be used exactly the same way as the designated value can be confusing if > one is not aware that the type is an access type. > I got it. Thank you all for your replies specially for Jeffrey's detailed explanation. Anh Vo