Version 1.1 of acs/ac-00300.txt

Unformatted version of acs/ac-00300.txt version 1.1
Other versions for file acs/ac-00300.txt

!standard 8.2(3)          18-01-11 AC95-00300/00
!class Amendment 18-01-11
!status received no action 18-01-11
!status received 17-12-04
!subject Private entities in the middle
!summary
!appendix

!topic Private entities in the middle
!reference Ada 2012 RM8.2(pp)
!from Victor Porton 17-11-04
!keywords private part
!discussion

It often appears the situation when we want to use an entity from another
package:

with T;
package X is
  ...
  subtype Y is Z.A;
end X;

In this case we need either add

  package Z renames T;

or add

use T;

Both a bad. You know that "use" is often bad. But

  package Z renames T;

is bad too, because we may not want to create the entity Z in X.

I propose to make the declaration of Z private with this syntax:

  private: package Z renames T;

More generally, I propose to make any declaration (in a package, task unit, or
protected unit) private by adding "private:".

This allows to declare our Y without unnecessary public declaration of Z and
without "use T;".

***************************************************************

From: Pascal Obry
Sent: Monday, December 4, 2017  11:11 AM

> I propose to make the declaration of Z private with this syntax:
> 
>   private: package Z renames T;

I won't comment about the usefulness of the proposal, but this does not look
like Ada to me. Maybe:

     package Z private renames T;

?

***************************************************************

From: Victor Porton
Sent: Monday, December 4, 2017  11:13 AM

It seems that you syntax applies ONLY to renaming declarations. My syntax is
for EVERY kind of entity.

***************************************************************

From: Pascal Obry
Sent: Monday, December 4, 2017  11:44 AM

And so?

What are the other declarations? Can't we use the same syntax? In which entity
are you proposing to add private support?

I'm pretty sure your syntax won't get accepted as it looks like a label. But
if you insist about this syntax, fine.

***************************************************************

From: Randy Brukardt
Sent: Monday, December 4, 2017  1:33 PM

...
> I propose to make the declaration of Z private with this syntax:
> 
>   private: package Z renames T;
> 
> More generally, I propose to make any declaration (in a package, task 
> unit, or protected unit) private by adding "private:".
> 
> This allows to declare our Y without unnecessary public declaration of 
> Z and without "use T;".

We've looked at various ways to allow visible declarations after private
declarations, and they all have run into semantic problems. (And if one
eliminates the semantic problems with restrictions, you end up with something
that you can do with child packages.) The most recent attempt was in
AI05-0074-2.

I agree with Pascal Obry that the syntax will never fly; it is too much like
block labels and object declarations.

I don't think you really want "private". A private declaration can have
(almost) no influence on any visible declaration; that leads to "private
leakage", where information about the private part changes the semantics of
the visible part for clients. This is a significant maintenance hazard, in 
that changes to the private part could change clients (legality in
particular). An important difference between Ada and most other languages is
that we do not tolerate "private leakage" and thus changing the implementation
of a package cannot make any clients illegal. (Most other languages don't
worry about this problem.)

Thus, making an entity private essentially means that it cannot be used in the
visible declarations. I don't think that is what you want; if it was
sufficient, you could have declared Z in the private part and no language
change would be needed. So, most likely you are looking for a way to hide a
declaration without hiding its semantics; that deserves a different term than
"private" (which is much stricter). Perhaps call it "hidden". So perhaps
declare your renaming as:

   hidden package Z renames T;

That does use a new reserved word, which would raise the bar for its
acceptance. But you have that problem anyway, as you are suggesting a new kind
of visibility. That also has a high bar for acceptance, as it would have
significant effects on both the Standard and on implementations. (Ada defines
visibility by scopes; you are looking for a visibility mechanism outside of
that scoping. That's a significant change.)

It might be helpful if you could explain a specific case where this feature
would be useful. Your problem statement is rather abstract, and does not allow
for any other solution. But perhaps there is some other solution to your
actual problem.

***************************************************************

From: Niklas Holsti
Sent: Monday, December 4, 2017  2:40 P

> In this case we need either add
>
>   package Z renames T;
>
> or add
>
> use T;
>
> Both a bad.

I don't see the point. Why not simply:

   subtype Y is T.A;

Why insist on a "rename" or "use" of T?

***************************************************************

From: Victor Porton
Sent: Monday, December 4, 2017  3:03 PM

> I don't see the point. Why not simply:
> 
>    subtype Y is T.A;

Because T may be a long, multilevel name. And it could be repeated when
defining Y1, Y2, ..., Yn.

***************************************************************

Questions? Ask the ACAA Technical Agent