comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Ada202X: Easy to use "UML private"-like components
Date: Sun, 23 Jun 2013 11:28:24 -0400
Date: 2013-06-23T11:28:24-04:00	[thread overview]
Message-ID: <wccppvc26ef.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: f4d00f07-6220-464b-982e-cd7b67169ad6@googlegroups.com

Shark8 <onewingedshark@gmail.com> writes:

> On Sunday, June 23, 2013 7:12:53 AM UTC-6, Robert A Duff wrote:
>> 
>> 
>> On the other hand, the private part kludge wouldn't be so bad if
>> the syntax were different:
>
> Perhaps something like this?

No, that's not at all what I meant.  I meant that a package would
come in three parts:

    package P is
        ...
    end P;

    package private P is -- Just making up syntax here.
        ...
    end P;

    package body P is
        ...
    end P;

Normally stored in 3 separate source files.  There would be no
private part syntax like we currently have.

I'm not suggesting this is the best idea -- I'm just suggesting
that it would fit in with the compilation model the Ada 83 designers
had in mind.  I would ditch that model, thus making the above
suggestion irrelevant.

> Package Example is
>    Type Opaque is private;
> private
>    Type Opaque is separate COMPLETE_NAME;
>    -- This flags to the compiler that the full type appears in the
>    -- package body (as COMPLETE_NAME) and the public 'Opaque' is
>    -- actually a pointer/reference/(not null access) to COMPLETE_NAME,
>    -- also any primitive ops for Opaque are transitively private ops 
>    -- of COMPLETE_NAME.
> end;

No, it's a bad idea to force the explicit use of pointer/heap when it's
not logically necessary.  C does that a lot.  Ada less, but it could
be even less.

>>  The private part should be a separate
>> syntactic compilation_unit, with its own with clauses, and should
>> normally be stored in a separate source file from the visible part.
>
> I don't know. Certainly for consistency's sake yes, but getting
> compiler writers to implement that as well might have been a
> death-knell for Ada 83.

My suggestion is trivial to implement.  And it wouldn't be "as well",
it would be "instead of".

>...Moreover, we would need some way to flag
> there isn't a PRIVATE area, like PRIVATE IS NULL; (Or conversely have
> the private section optionally in the spec, as it is now, but with
> PRIVATE IS SEPARATE as the trigger for an external private section.)

No, my suggestion is that there is NEVER a "private area", so there's
no need to indicate that there is none.

I'm not suggesting this as a change to Ada -- I'm suggesting that
it would have been a better way to design Ada 83.

>> There's an awful lot of horrible code duplication caused by the
>> fact that the private part is in the same file as the visible part.
>
> I'm not sure about that. Consider this:
> Type K;
>
> Type J is record
>  Item : K; -- might need to be access K.
> end record;
>
> Type K is new Integer Range 0..100;
>
> Sure "Type K" appears twice, but that's required so that we have some
> name for the type of J.Item. The items (full declarations) in the
> PRIVATE section are likewise.

Sorry, I wasn't clear.

That's not the duplication I'm talking about.  I'm talking about the
case where you have an abstraction with multiple implementations.
This happens often in the GNAT runtimes, for example.  Since the
private part is part of the implementation, you need multiple copies
of it for different platforms/environments.  Given Ada as it is,
that forces you to make multiple copies of the visible part,
which is a violation of the DRY principle.

- Bob


  reply	other threads:[~2013-06-23 15:28 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-21  8:43 Ada202X: Easy to use "UML private"-like components Martin
2013-06-21  9:23 ` Dmitry A. Kazakov
2013-06-21  9:33   ` Martin
2013-06-21 10:14     ` G.B.
2013-06-21 11:19       ` Martin
2013-06-21 14:51     ` Dmitry A. Kazakov
2013-06-22 11:16       ` Martin
2013-06-22 12:10         ` Dmitry A. Kazakov
2013-06-21 18:36 ` Robert A Duff
2013-06-22 16:41   ` Niklas Holsti
2013-06-22 19:05     ` Dennis Lee Bieber
2013-06-22 22:57       ` Niklas Holsti
2013-06-23  3:26         ` Dennis Lee Bieber
2013-06-23  7:32           ` Niklas Holsti
2013-06-23 13:12             ` Robert A Duff
2013-06-23 14:06               ` Dmitry A. Kazakov
2013-06-23 15:15                 ` Robert A Duff
2013-06-23 18:52                   ` Dmitry A. Kazakov
2013-06-23 23:38                     ` Robert A Duff
2013-06-24  7:16                       ` Dmitry A. Kazakov
2013-06-24 20:11                         ` Randy Brukardt
2013-06-25  7:21                           ` Dmitry A. Kazakov
2013-06-25 19:06                             ` Randy Brukardt
2013-06-24 20:07                 ` Randy Brukardt
2013-06-23 14:40               ` Shark8
2013-06-23 15:28                 ` Robert A Duff [this message]
2013-06-23 18:14                   ` Bill Findlay
2013-06-23 23:43                     ` Robert A Duff
2013-06-23 23:48                       ` Bill Findlay
2013-06-24 20:16                   ` Randy Brukardt
2013-06-24 20:05               ` Randy Brukardt
2013-06-25  1:09                 ` Robert A Duff
2013-06-25 19:37                   ` Randy Brukardt
2013-06-23 12:28         ` Robert A Duff
2013-06-24 20:20           ` Randy Brukardt
2013-06-24 21:40             ` Niklas Holsti
2013-06-25  0:43               ` Robert A Duff
2013-06-25 19:23                 ` Randy Brukardt
2013-06-25 19:19               ` Randy Brukardt
2013-07-09 11:24   ` Martin
2013-07-09 14:39     ` Simon Wright
2013-07-10  7:03       ` Martin
2013-07-09 21:43     ` Robert A Duff
2013-07-10  6:34       ` Martin
2013-07-10  8:24         ` Dmitry A. Kazakov
2013-07-10 13:06           ` Martin
2013-07-10 16:12     ` Simon Wright
2013-07-10 18:22       ` Martin
2013-07-10 19:41         ` Simon Wright
2013-07-11 18:28           ` Martin
2013-07-11 19:37             ` Simon Wright
2013-07-11 20:43               ` Martin
2013-07-12  6:57                 ` Simon Wright
2013-07-12  8:05                   ` Martin
replies disabled

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