comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: In mode parameter in an assignment statement
Date: Sat, 13 Oct 2018 10:38:01 +0200
Date: 2018-10-13T10:38:01+02:00	[thread overview]
Message-ID: <ppsat9$pgn$1@dont-email.me> (raw)
In-Reply-To: <82fdea5d-b9b6-4f1e-a45f-ee0ff9f55946@googlegroups.com>

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.

-- 
Jeff Carter
It's better to be root than to reboot.
119

  parent reply	other threads:[~2018-10-13  8:38 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 [this message]
2018-10-15 16:05   ` Anh Vo
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox