comp.lang.ada
 help / color / mirror / Atom feed
From: Jere <jhb.chat@gmail.com>
Subject: Re: non record limited type
Date: Wed, 21 Feb 2018 15:08:05 -0800 (PST)
Date: 2018-02-21T15:08:05-08:00	[thread overview]
Message-ID: <5da1106b-58f5-4d3c-a564-3a530b99042a@googlegroups.com> (raw)
In-Reply-To: <6e384796-4a5f-449a-8bf7-3b8fe974b4fc@googlegroups.com>

On Wednesday, February 21, 2018 at 5:29:11 PM UTC-5, Mehdi Saada wrote:
> > Based on that, your limited private which is really an integer would still be
> > a by-copy-type.  I don't know the RM's intention but the wording suggests that
> > at least.  Note you can also used the "aliased" keyword in a function/procedure
> > signature to enforce an aliased variable which will be passed by reference
> > as well: 
> > -- Object is passed by reference
> > procedure Do_Something(Object : aliased in out Some_Type);
> 
> Really ? Are you sure it "forces" the passing by reference ? But I remember clearly have read somewhere, most probably on this forum that it wasn't in Ada's philosophy to let one precise that, since it is an implementation detail, and that the compiler shall decide by himself.

The rules are scattered about the RM, but if you look at the Ada2012 Rationale
document which was released with the RM:  
http://www.ada-auth.org/standards/rationale12.html

You will see it was a new feature added with the Ada2012 revision

Section 1.3.3
http://www.ada-auth.org/standards/12rat/html/Rat12-1-3-3.html
---------------------
An aliased parameter is always passed by reference and the accessibility 
rules are modified accordingly. This facility is used in a revision to 
the containers which avoids the need for expensive and unnecessary copying 
of complete elements when they are updated. The details will be given 
in Sections 4.2 and 6.3.



Section 4.2
http://www.ada-auth.org/standards/12rat/html/Rat12-4-2.html
---------------------
The other change in Ada 2012 concerning parameters is that they may be 
explicitly marked aliased thus

procedure P(X: aliased in out T; ... );

As a consequence within P we can write X'Access. Recall that tagged types 
were always considered implicitly aliased anyway and always passed by 
reference. If the type T is a by-copy type such as Integer, then adding 
aliased causes it to be passed by reference. (So by-copy types are not 
always passed by copy!)



Section 6.3
http://www.ada-auth.org/standards/12rat/html/Rat12-6-3.html
----------------------
The alert reader will note the inclusion of aliased for the parameter 
Container of the function Reference. As discussed in Section 4.2 on 
subprogram parameters, this ensures that the parameter is passed by 
reference (it always is for tagged types anyway); it also permits us 
to apply 'Access to the parameter Container within the function and to 
return that access value.

  reply	other threads:[~2018-02-21 23:08 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-21 15:58 non record limited type Mehdi Saada
2018-02-21 21:42 ` Jere
2018-02-21 22:29   ` Mehdi Saada
2018-02-21 23:08     ` Jere [this message]
2018-02-21 23:14     ` Jere
2018-02-22  0:09       ` Mehdi Saada
2018-02-22  0:26         ` Mehdi Saada
2018-02-22  2:57           ` Jere
2018-02-22 16:45         ` Jeffrey R. Carter
2018-02-22 17:06           ` Dmitry A. Kazakov
2018-02-22  7:56       ` Simon Wright
2018-02-22  1:20     ` Randy Brukardt
2018-02-22  1:29 ` Randy Brukardt
2018-02-22  8:25   ` Dmitry A. Kazakov
2018-02-22 23:24     ` Randy Brukardt
2018-02-23  8:58       ` Dmitry A. Kazakov
replies disabled

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