comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: 'Protected' abstract subprograms
Date: Wed, 15 Jan 2014 09:11:03 -0500
Date: 2014-01-15T09:11:03-05:00	[thread overview]
Message-ID: <wcck3e18he0.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 1aav8alqsnqqv.5urmifgwh1mv.dlg@40tude.net

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

> Hmm, of course they can and do. Do you mean legality of public part not
> depending on the legality of private parts? Even they do.

I think the principle is:

    The private part cannot affect the legality of clients.

It seems like a good principle, but it is violated all over the place.
Search for "see 12.3" in the RM to find a bunch.  For example:

    generic
       type Formal is tagged limited private;
    package A is
    private
       task type T;
       type Derived is new Formal with record
         Limited_Component: T;
       end record;
    end;

    with A;
    package B is
       type Actual is tagged null record;
       package Instance is new A(Actual);
    end;

Package B is illegal, because of something going on the private
part of A -- without Limited_Component it would be legal.
With Limited_Component, B.Instance.Derived is a nonlimited type
with a limited component, which is illegal.

I think maybe this is an indication that Ada's macro-expansion model
of generics is a wrong approach.

> Yep, that's what I meant under "cooperative" privacy. For many
> applications, and the number of is growing rapidly, a "non-cooperative"
> privacy is needed as well.

Well, in a language that allows Unchecked_Conversion, address clauses,
machine code inserts, etc., I don't see any way to achieve
non-cooperative privacy within a single process.  You can achieve it
in Ada via remote procedure calls, though.

> Just one trivial example of slack privacy. You cannot hide default values:
> 
>    type T is private;

If you have:

    function V return T;

then the default value is hidden.

>    procedure Foo (X : T := V);
> private
>    type T is ...
> 
> Should have been something like:
> 
>    type T is private;
>    procedure Foo (X : T := <>); -- The value is deferred
> private
>    type T is ...
>    for Foo'Default (X) use V; -- Here it is, whichever syntax you prefer

I don't see a need for any such feature.

- Bob

  reply	other threads:[~2014-01-15 14:11 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-10 22:00 'Protected' abstract subprograms sbelmont700
2014-01-10 22:30 ` Randy Brukardt
2014-01-11 16:12   ` sbelmont700
2014-01-14  3:45     ` Randy Brukardt
2014-01-14  9:05       ` Dmitry A. Kazakov
2014-01-15  0:36         ` Randy Brukardt
2014-01-15  9:17           ` Dmitry A. Kazakov
2014-01-15 14:11             ` Robert A Duff [this message]
2014-01-15 15:40               ` adambeneschan
2014-01-15 21:21                 ` Robert A Duff
2014-01-15 23:10                   ` Randy Brukardt
2014-01-16  0:51                     ` Robert A Duff
2014-01-16 10:43                       ` AdaMagica
2014-01-16 16:32                         ` adambeneschan
2014-01-17  1:49                         ` Robert A Duff
2014-01-17 23:23                           ` Randy Brukardt
2014-01-19 21:07                             ` Robert A Duff
2014-01-20  8:40                               ` Dmitry A. Kazakov
2014-01-21 14:37                                 ` Robert A Duff
2014-01-22  8:27                                   ` Dmitry A. Kazakov
2014-01-21  1:21                               ` Randy Brukardt
2014-01-21 14:35                                 ` Robert A Duff
2014-01-15 23:17               ` Randy Brukardt
2014-01-16  8:52               ` Dmitry A. Kazakov
2014-01-11  8:41 ` J-P. Rosen
2014-01-11  8:59 ` Dmitry A. Kazakov
2014-01-11 13:42   ` Niklas Holsti
2014-01-11 19:35     ` Dmitry A. Kazakov
2014-01-12  9:19       ` Niklas Holsti
2014-01-12 10:22         ` 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