From: Anh Vo <anhvofrcaus@gmail.com>
Subject: Re: In mode parameter in an assignment statement
Date: Mon, 15 Oct 2018 09:05:47 -0700 (PDT)
Date: 2018-10-15T09:05:47-07:00 [thread overview]
Message-ID: <436802a9-a7ee-4ce0-9f16-948f1b3a3441@googlegroups.com> (raw)
In-Reply-To: <ppsat9$pgn$1@dont-email.me>
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
prev parent reply other threads:[~2018-10-15 16:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-13 0:48 In mode parameter in an assignment statement Anh Vo
2018-10-13 5:52 ` Jacob Sparre Andersen
2018-10-13 6:03 ` Per Sandberg
2018-10-13 8:38 ` Jeffrey R. Carter
2018-10-15 16:05 ` Anh Vo [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox