comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: Derived private interface
Date: Wed, 06 Jul 2011 14:59:38 +0200
Date: 2011-07-06T14:59:38+02:00	[thread overview]
Message-ID: <4e145c3a$0$6542$9b4e6d93@newsspool4.arcor-online.net> (raw)
In-Reply-To: <4b2728fc-6127-45d8-a314-9fc491701c26@g12g2000yqd.googlegroups.com>

On 06.07.11 10:30, AdaMagica wrote:
> On 6 Jul., 09:55, Georg Bauhaus <rm.dash-bauh...@futureapps.de> wrote:
>> On 7/6/11 6:34 AM, AdaMagica wrote:
>>
>>> I should have written
>>
>>>    overriding procedure Doit (X: access Derived_Class);
>>

> In both cases, if the compiler suddenly complains when before
> everything was OK, something in the hierarchy below the actual type
> must have changed. Without those keywords, you will never be informed
> and will spend hours or days debugging.

Besides these cases, there are other cases that will make the
compiler complain only if a programmer has placed overriding_indicators.
With good reason, from his or her point of view.

If a programmer's intent has been to express overriding status, but, when
trying to do so, he or she did not understand the full set of rules
that restrict the set of permissible places for overriding_indicator,
the compiler's complaint may generate anger more than anything else.

And maybe that anger is justified.

That is, in this programming situation involving non-overriding
operations, the [not] overriding_indicator does not entail measures
against the effects of typos (the feature's purpose as stated in the RM).
But it may well create confusion.  Even when some lengthy formal
exegesis will permit putting the blame on the programmer, this does
not seem helpful.  I can't think this has been an intent, either.

The LRM rules regulating overriding_indicator seem to have been
derived form Ada's O-O logic and visibility.  Not so much from the
more general programming situation where any indicators would
instead cater to programmers' intentions, IMHO.

overriding_indicators are all logical and such, and I'll accept it
if they cannot be designed any better.  But somehow I like package C4
below a lot more than I like the others.

(The error message at L.26 and L.37, taken together, are---per
se---confusing, aren't they?)

Example:

Compilation started at Wed Jul  6 11:13:55

gnatmake -gnatwa -gnatvf -gnatl ovrd.ads
gcc -c -gnatwa -gnatvf -gnatl ovrd.ads

GNAT 4.7.0 20110610 (experimental)
Copyright 1992-2011, Free Software Foundation, Inc.


Compiling: ovrd.ads (source file time stamp: 2011-07-06 11:13:47)

     1. package Ovrd is
     2.
     3.     package P1 is
     4.
     5.         type T1 is abstract tagged private;
     6.         procedure Op (X : in out T1) is abstract;
     7.
     8.     private
     9.         type T1 is abstract tagged null record;
    10.     end P1;
    11.
    12.     package P2 is
    13.
    14.         type T2 is new P1.T1 with private;
    15.         procedure Oops (X : in out T2);
    16. 	--  typo, possibly not caught by soundex algorithm etc, but...
    17.     private
    18.         type T2 is new P1.T1 with null record;
                     |
        >>> type must be declared abstract or "Op" overridden
        >>> "Op" has been inherited at line 14
        >>> "Op" has been inherited from subprogram at line 6

    19.     end P2;
    20.
    21.
    22.     package C1 is
    23.
    24.         type T1 is private;
    25.         not overriding  -- E!  `Op` overrides invisibly (in private part)
    26.         procedure Op (X : in out T1);
                |
        >>> subprogram "Op" overrides inherited operation at line 29

    27.
    28.     private
    29.         type T1 is new P1.T1 with null record;
    30.     end C1;
    31.
    32.
    33.     package C2 is
    34.
    35.         type T1 is private;
    36.         overriding  -- E!  Overriding? Yes, but privately
    37.         procedure Op (X : in out T1);
                |
        >>> subprogram "Op" is not overriding

    38.
    39.     private
    40.         type T1 is new P1.T1 with null record;
    41.     end C2;
    42.
    43.
    44.     package C3 is
    45.
    46.         type T1 is private;
    47. 	not overriding  -- OK, not overriding in any place
    48. 	procedure Op (X : in out T1);
    49.
    50.     private
    51.         type T1 is null record;
    52.     end C3;
    53.
    54.
    55.     package C4 is
    56.
    57.         type T1 is private;
    58. 	--  Overriding status is not known.  Should we care
    59. 	--  in this case, for a type that is simply private?
    60.         procedure Op (X : in out T1);
    61.
    62.     private
    63.         type T1 is new P1.T1 with null record;
    64.     end C4;
    65.
    66.
    67.     package C5 is
    68.
    69.         type T1 is private;
    70. 	--  No more `Op`
    71.
    72.     private
    73.         type T1 is new P1.T1 with null record;
    74. 	overriding  -- correct, overriding at this place
    75. 	procedure Op (X : in out T1);
    76.     end C5;
    77.
    78. end Ovrd;

 78 lines: 5 errors
gnatmake: "ovrd.ads" compilation error

Compilation exited abnormally with code 4 at Wed Jul  6 11:13:55



  reply	other threads:[~2011-07-06 12:59 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-05  3:14 Derived private interface Rego, P.
2011-07-05  5:10 ` AdaMagica
2011-07-06  2:24   ` Rego, P.
2011-07-06  4:34   ` AdaMagica
2011-07-06  7:55     ` Georg Bauhaus
2011-07-06  8:30       ` AdaMagica
2011-07-06 12:59         ` Georg Bauhaus [this message]
2011-07-06 13:23           ` AdaMagica
2011-07-06 19:06             ` Randy Brukardt
2011-07-06 13:28           ` Simon Wright
2011-07-06 19:45           ` Randy Brukardt
2011-07-06 22:05             ` Georg Bauhaus
2011-07-06 23:56               ` Adam Beneschan
2011-07-07 14:09                 ` Georg Bauhaus
2011-07-07 15:10                   ` Adam Beneschan
2011-07-08  4:29                     ` AdaMagica
2011-07-08 19:08                       ` Randy Brukardt
2011-07-08 19:12                     ` Randy Brukardt
2011-07-07 15:19                   ` Georg Bauhaus
2011-07-07 10:37         ` Stephen Leake
2011-07-07 13:18           ` Georg Bauhaus
2011-07-08 19:23             ` Randy Brukardt
2011-07-08 21:41               ` Jeffrey Carter
2011-07-09  6:14                 ` Dmitry A. Kazakov
2011-07-22 22:59                 ` Randy Brukardt
2011-07-23  7:30                   ` Jeffrey Carter
2011-07-23  9:29                     ` Maciej Sobczak
2011-07-23 10:07                     ` Dmitry A. Kazakov
2011-07-26 21:04                     ` Randy Brukardt
2011-07-26 23:43                       ` Jeffrey Carter
2011-07-27 23:56                         ` Randy Brukardt
2011-07-28  0:18                           ` Jeffrey Carter
2011-07-28 10:06                         ` Maciej Sobczak
2011-07-28 23:24                           ` Randy Brukardt
2011-07-29  6:45                             ` Simon Wright
2011-07-30  0:04                               ` Randy Brukardt
2011-07-30  6:32                                 ` Simon Wright
2011-08-01  9:30                                   ` Alex R. Mosteo
2011-08-01 10:12                                     ` Dmitry A. Kazakov
2011-08-01 21:56                                       ` Randy Brukardt
2011-08-02 10:03                                         ` Dmitry A. Kazakov
2011-08-02 21:16                                           ` Randy Brukardt
2011-08-03  9:01                                             ` Dmitry A. Kazakov
2011-08-03 20:16                                               ` Randy Brukardt
2011-08-04  8:15                                                 ` Dmitry A. Kazakov
2011-08-09 21:10                             ` Maciej Sobczak
2011-08-09 21:35                               ` Randy Brukardt
2011-08-10  9:11                                 ` Dmitry A. Kazakov
2011-08-10 21:56                                   ` Randy Brukardt
2011-08-11  8:07                                     ` Dmitry A. Kazakov
2011-08-12  4:52                                       ` Randy Brukardt
2011-08-12  8:54                                         ` Dmitry A. Kazakov
2011-08-10 10:07                                 ` Maciej Sobczak
2011-08-10 11:26                                   ` Georg Bauhaus
2011-08-10 22:27                                     ` Randy Brukardt
2011-08-10 22:21                                   ` Randy Brukardt
2011-08-11 13:50                                     ` Maciej Sobczak
2011-08-12  4:43                                       ` Randy Brukardt
2011-08-12  7:00                                         ` Maciej Sobczak
2011-08-12 21:59                                           ` Randy Brukardt
2011-07-06 15:06       ` Adam Beneschan
2011-07-06 16:36       ` Dmitry A. Kazakov
2011-07-06 19:20       ` Randy Brukardt
replies disabled

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