comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Your wish list for Ada 202X
Date: Fri, 18 Apr 2014 16:28:58 -0500
Date: 2014-04-18T16:28:58-05:00	[thread overview]
Message-ID: <lis5et$gt1$1@loke.gir.dk> (raw)
In-Reply-To: brdegqFi62jU1@mid.individual.net

"Niklas Holsti" <niklas.holsti@tidorum.invalid> wrote in message 
news:brdegqFi62jU1@mid.individual.net...
> On 14-04-17 01:27 , Randy Brukardt wrote:
>> "Niklas Holsti" <niklas.holsti@tidorum.invalid> wrote in message
>> news:br8bu5Fg3keU1@mid.individual.net...
>>> On 14-04-15 03:08 , Randy Brukardt wrote:
...
>> There's also the point that a
>> dispatching call always has to be assumed to be to some body not even
>> written yet, so it's nearly impossible to say anything definitive about 
>> it's
>> contract.
>
> But the operation has been *specified*, even if no bodies exist,
> therefore the contract *from the caller's point of view* should have
> been defined. Otherwise there is not much point in using a class at all,
> or indeed in separating operation declarations and bodies.

Right, but here I'm a practicalist, rather than theortician. Humans write 
programs, and they tend to ignore anything not convinient. That certainly 
goes for whatever part of the contract is not formally specified and 
checked. So there is a lot more risk from re-dispatching than static 
binding, simply because there is more likelihood of error (unintentional or 
malicious).

>> ...
>>>> This last issue doesn't arise for a class-wide operation, where every
>>>> call is going to look at an object of TT as type TT.
>>>
>>> Except if TT inherits some operation from T, because then that operation
>>> looks at the object as type T. (I know that from the language-semantics
>>> point of view the inherited operation acts on TT, but the programmer
>>> wrote its code with T in mind.)
>>>
>>> If redispatching is suspect because it breaks the assocation of an
>>> operation with a unique type, then inheritance of operations must also
>>> be suspect, for the same reason.
>>
>> I understand your point, but I think the language-semantics view is 
>> actually
>> the correct one. One only allows inheritance of operations when the
>> implementation for T and for TT is thought to be identical. One hopes 
>> that
>> the author of TT considered that carefully!
>
> Well, I use redispatching only when I think that the operation being
> called is well specified and is or will be carefully implemented for
> each type in the class, as appropriate for that type. Same difference :-)

If you truly believe that you can "well specify" and "carefully implement" 
everything in your system, well, you're a better man than me. :-) I don't 
believe that about my code even when I write the entire thing at one time - 
much less when other people are involved or years pass between work. One of 
the things that attracted me to Ada in the first place is that it forces me 
to specify enough that it prevents many of my worst impulses. (Instantiating 
Unchecked_Conversion is painful enough to prevent most reuse of objects, for 
one example.) I doubt I'd ever get a lengthy C program to work!

>> It's true that maintenance of the T operation might in fact break the TT
>> operation (meaning that they should have different implementations), so
>> there is some additional danger in inheritance.
>
> Yes. In general, the more a program is "factored" into parts that are
> combined and invoked in many contexts, the harder it becomes to maintain
> proper behaviour in all contexts. Subprograms, inheritance, dispatching,
> redispatching all tend in this direction.

Right.

>> There is also danger in
>> inheritance that the author of TT didn't know about. (I think it would be
>> much better if all inheritance was explicit; but to be practical that 
>> would
>> require a rather different syntax than Ada uses, and thus such a thing 
>> would
>> not make sense in an Ada perspective.
>
> To make inheritance explicit, it seems to me that each inherited
> operation must be declared for the derived type, with its full profile,
> perhaps as
>
>   inherited procedure Foo (X: in T; ....);
>
> This would require just one new reserved word, "inherited", and does not
> feel like a "rather different syntax". Did you have something else in 
> mind?

The problem with this sort of syntax is that it's really wordy and tends to 
obscure the important issues (which is not the exact profile, as least 
unless you have a resolution problem). Remember all of the people that used 
renames to avoid using use clauses for Ada 83? (Maybe not, that was a long 
time ago.) They often had bugs like:
   function "+" (Left, Right : P.Big_Int) return P.Big_Int renames P."-";
where the profile is obscuring the critical differences.

I'd prefer a much simpler declaration of inheritance, something like:
   type Child is new Parent with ...
      with inherits => Foo, Bar, Blech;

where names not listed are hidden from all visibility unless overridden. 
(The Ada dispatching model insists that the routines exist, so for Ada all 
one could do would be to hide any uninherited operations from direct calls. 
One could imagine have uninherited operations raise Program_Error in 
dispatching as an alternative, but that's not ideal either because it makes 
a tripping hazard as Bob calls it. Thirdly, one could require all operations 
to be either inherited or overridden, but that just makes a new kind of pain 
for deriving types, especially for those of us who prefer incremental 
implementation of things).

Whether that's enough or if some alternative with optional profiles is 
necessary, I don't know. Most operations aren't overloaded, after all, so 
the profile is just noise.

                       Randy.




  reply	other threads:[~2014-04-18 21:28 UTC|newest]

Thread overview: 240+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-25 21:41 Your wish list for Ada 202X Stoik
2014-03-25 22:14 ` Simon Wright
2014-03-26  6:25 ` Shark8
2014-03-26 20:41   ` Randy Brukardt
2014-03-27  9:20     ` Shark8
2014-03-27 21:50       ` Randy Brukardt
2014-03-28  1:54         ` Jeffrey Carter
2014-03-28  8:17         ` Dmitry A. Kazakov
2014-03-28 21:27           ` Randy Brukardt
2014-03-29  9:44             ` Dmitry A. Kazakov
2014-03-31 23:55               ` Randy Brukardt
2014-04-01  8:20                 ` Dmitry A. Kazakov
2014-04-01 10:51                   ` G.B.
2014-04-01 12:40                     ` Dmitry A. Kazakov
2014-04-02 22:39                   ` Randy Brukardt
2014-04-03  2:59                     ` Shark8
2014-04-05 11:10                     ` Dmitry A. Kazakov
2014-04-08  1:15                       ` Randy Brukardt
2014-04-08  9:15                         ` Dmitry A. Kazakov
2014-04-08 10:15                           ` G.B.
2014-04-08 10:56                             ` Dmitry A. Kazakov
2014-04-08 23:37                           ` Randy Brukardt
2014-04-09 10:40                             ` Dmitry A. Kazakov
2014-04-10  3:28                               ` Randy Brukardt
2014-04-10  8:42                                 ` Georg Bauhaus
2014-04-10 21:52                                   ` Randy Brukardt
2014-04-10 15:31                                 ` Dmitry A. Kazakov
2014-04-10 22:08                                   ` Randy Brukardt
2014-04-11  6:20                                     ` Dmitry A. Kazakov
2014-04-11 21:34                                       ` Randy Brukardt
2014-04-10 22:39                                   ` Randy Brukardt
2014-04-11  6:40                                     ` Dmitry A. Kazakov
2014-04-11 21:44                                       ` Randy Brukardt
2014-04-12  8:45                                         ` Dmitry A. Kazakov
2014-04-14 23:39                                           ` Randy Brukardt
2014-04-15  7:55                                             ` Dmitry A. Kazakov
2014-04-15 21:27                                               ` Randy Brukardt
2014-04-16  7:52                                                 ` Dmitry A. Kazakov
2014-04-16 21:53                                                   ` Randy Brukardt
2014-04-17  7:39                                                     ` Dmitry A. Kazakov
2014-04-17 17:29                                                       ` Randy Brukardt
2014-04-17 19:54                                                         ` Dmitry A. Kazakov
2014-04-11 19:04                                   ` Niklas Holsti
2014-04-11 20:43                                     ` Dmitry A. Kazakov
2014-04-11 22:04                                       ` Niklas Holsti
2014-04-12  8:20                                         ` Dmitry A. Kazakov
2014-04-12  8:39                                           ` Nasser M. Abbasi
2014-04-12  9:38                                             ` Dmitry A. Kazakov
2014-04-12  9:55                                               ` Georg Bauhaus
2014-04-12 10:45                                                 ` Dmitry A. Kazakov
2014-04-14 23:45                                                   ` Randy Brukardt
2014-04-12 10:17                                               ` Nasser M. Abbasi
2014-04-12 10:48                                                 ` Dmitry A. Kazakov
2014-04-13 19:43                                           ` Niklas Holsti
2014-04-13 21:07                                             ` Dmitry A. Kazakov
2014-04-18 19:10                                               ` Niklas Holsti
2014-04-18 21:18                                                 ` Dmitry A. Kazakov
2014-04-19  7:35                                                   ` Niklas Holsti
2014-04-19  8:19                                                     ` Dmitry A. Kazakov
2014-04-19  8:39                                                       ` Dmitry A. Kazakov
2014-04-19  9:08                                                         ` Niklas Holsti
2014-04-19 10:06                                                           ` Dmitry A. Kazakov
2014-04-19 13:53                                                             ` Niklas Holsti
2014-04-19 14:21                                                               ` Dmitry A. Kazakov
2014-04-19 18:28                                                                 ` Niklas Holsti
2014-04-19  9:05                                                       ` Niklas Holsti
2014-04-19 10:18                                                         ` Dmitry A. Kazakov
2014-04-15  0:08                                             ` Randy Brukardt
2014-04-15  7:21                                               ` Natasha Kerensikova
2014-04-15 21:20                                                 ` Randy Brukardt
2014-04-16  6:32                                                 ` Niklas Holsti
2014-04-16  7:24                                                   ` Natasha Kerensikova
2014-04-16  7:31                                                   ` Dmitry A. Kazakov
2014-04-16  9:30                                                   ` Redispatching (was: Your wish list for Ada 202X) J-P. Rosen
2014-04-16 19:53                                                     ` Redispatching Niklas Holsti
2014-04-17  7:26                                                       ` Redispatching Dmitry A. Kazakov
2014-04-17  8:22                                                         ` Redispatching Georg Bauhaus
2014-04-18 20:08                                                         ` Redispatching Niklas Holsti
2014-04-18 20:51                                                           ` Redispatching Dmitry A. Kazakov
2014-04-19  9:17                                                             ` Redispatching Georg Bauhaus
2014-04-19 10:58                                                               ` Redispatching Dmitry A. Kazakov
2014-04-19 11:21                                                                 ` Redispatching Georg Bauhaus
2014-04-17  8:53                                                       ` Redispatching J-P. Rosen
2014-04-16 21:44                                               ` Your wish list for Ada 202X Niklas Holsti
2014-04-16 22:27                                                 ` Randy Brukardt
2014-04-18 19:59                                                   ` Niklas Holsti
2014-04-18 21:28                                                     ` Randy Brukardt [this message]
2014-04-19  8:14                                                       ` Niklas Holsti
2014-04-21 23:09                                                         ` Randy Brukardt
2014-04-22  6:08                                                           ` Niklas Holsti
2014-04-22  8:02                                                           ` Dmitry A. Kazakov
2014-04-22  8:30                                                             ` Shark8
2014-04-22  9:14                                                               ` Dmitry A. Kazakov
2014-04-22 23:23                                                                 ` Randy Brukardt
2014-04-23  7:45                                                                   ` Dmitry A. Kazakov
2014-04-23 19:43                                                                     ` Shark8
2014-04-23 20:00                                                                       ` Dmitry A. Kazakov
2014-04-23 21:28                                                                         ` Shark8
2014-04-24  7:30                                                                           ` Dmitry A. Kazakov
2014-04-24 15:20                                                                             ` Shark8
2014-04-24 16:19                                                                               ` Dmitry A. Kazakov
2014-04-24 16:50                                                                                 ` Shark8
2014-04-24 16:57                                                                                   ` Dmitry A. Kazakov
2014-04-19 10:02                                                       ` Georg Bauhaus
2014-03-27 22:06       ` Randy Brukardt
2014-03-28  5:23         ` Shark8
2014-03-26  8:17 ` Dmitry A. Kazakov
2014-03-26  9:02   ` J Kimball
2014-03-26  9:27     ` Dmitry A. Kazakov
2014-03-26 10:30       ` Marius Amado-Alves
2014-03-26 15:11         ` G.B.
2014-03-26 21:55       ` Simon Clubley
2014-03-26 15:03     ` G.B.
2014-03-26 22:00     ` Simon Clubley
2014-03-26 16:01   ` Anh Vo
2014-03-26 17:04     ` Dmitry A. Kazakov
2014-03-27 15:03       ` Dan'l Miller
2014-03-27 16:02         ` Dmitry A. Kazakov
2014-03-26 16:17   ` Stoik
2014-03-26 17:15     ` Dmitry A. Kazakov
2014-03-26 18:04     ` G.B.
2014-03-26 18:47       ` Simon Wright
2014-03-26 19:51         ` Georg Bauhaus
2014-03-27 14:43       ` Jacob Sparre Andersen
2014-03-27 22:50         ` Randy Brukardt
2014-03-28  5:22           ` J-P. Rosen
2014-03-28  7:54           ` Jacob Sparre Andersen
2014-03-28 21:22             ` Randy Brukardt
2014-03-26 21:06     ` Randy Brukardt
2014-03-26 23:15       ` J Kimball
2014-03-27  8:26       ` Dmitry A. Kazakov
2014-03-27 10:54         ` Georg Bauhaus
2014-03-27 15:42           ` Dmitry A. Kazakov
2014-03-27 21:35         ` Randy Brukardt
2014-04-29 14:26       ` Tero Koskinen
2014-04-29 15:39         ` Dan'l Miller
2014-04-29 17:10         ` Simon Clubley
2014-04-29 17:13           ` Tero Koskinen
2014-04-29 19:42             ` Simon Clubley
2014-03-30 12:28 ` francois_fabien
2014-03-30 13:40   ` Luke A. Guest
2014-03-30 14:24     ` Simon Clubley
2014-03-30 18:48       ` Luke A. Guest
2014-03-30 19:22         ` Dmitry A. Kazakov
2014-03-30 14:28     ` Simon Clubley
2014-03-30 15:14       ` Peter Chapin
2014-03-30 18:48         ` Luke A. Guest
2014-03-30 18:48       ` Luke A. Guest
2014-03-30 23:41         ` Simon Clubley
2014-03-31 15:39     ` Adam Beneschan
2014-03-30 13:46   ` Simon Clubley
2014-03-30 19:02   ` Pascal Obry
2014-03-30 19:33     ` Dmitry A. Kazakov
2014-03-30 19:59       ` Pascal Obry
2014-03-31 15:13         ` Stoik
2014-03-31 16:22           ` Pascal Obry
2014-03-31 16:47           ` Pascal Obry
2014-03-31 18:59           ` Dmitry A. Kazakov
2014-04-05  8:28       ` Pascal Obry
2014-04-05 11:06         ` Georg Bauhaus
2014-04-05 11:20           ` Pascal Obry
2014-04-02 16:21 ` Britt
2014-04-02 22:53   ` Randy Brukardt
2014-04-03  0:01     ` Jeffrey Carter
2014-04-03  5:51       ` Pascal Obry
2014-04-03  6:27         ` Jeffrey Carter
2014-04-03 17:18           ` Pascal Obry
2014-04-03 19:11             ` Dan'l Miller
2014-04-03 19:18             ` Dan'l Miller
2014-04-03 21:17             ` Randy Brukardt
2014-04-04  0:29               ` Jeffrey Carter
2014-04-04  8:20                 ` Stefan.Lucks
2014-04-04 19:52                   ` J Kimball
2014-04-04 20:43                     ` Randy Brukardt
2014-04-04 20:54                       ` Shark8
2014-04-04 21:47                       ` Luke A. Guest
2014-04-08  0:47                         ` Randy Brukardt
2014-04-08  4:43                           ` J Kimball
2014-04-08  5:25                             ` Jeffrey Carter
2014-04-08 23:44                             ` Randy Brukardt
2014-04-04 20:53                 ` Randy Brukardt
2014-04-04 23:25                   ` Jeffrey Carter
2014-04-03  6:30         ` Georg Bauhaus
2014-04-03  0:06     ` Britt
2014-04-03 15:15   ` Robert A Duff
2014-04-03 20:19     ` Qun-Ying
2014-04-03 22:56       ` Robert A Duff
2014-04-04 18:31 ` Dan'l Miller
2014-04-04 21:08   ` Randy Brukardt
2014-04-05  3:39   ` Peter Chapin
2014-04-04 20:27 ` Shark8
2014-04-14  4:59 ` J Kimball
2014-04-14  6:54   ` Shark8
2014-04-15  0:22     ` Randy Brukardt
2014-04-15  0:18   ` Randy Brukardt
2014-04-15  5:28     ` J Kimball
2014-04-14 22:36 ` Shark8
2014-04-15  8:41   ` J-P. Rosen
2014-04-18  0:55 ` Robert Love
2014-04-18 11:39   ` Simon Wright
2014-04-23 12:55 ` björn lundin
2014-04-23 13:57   ` J-P. Rosen
2014-04-23 14:32     ` björn lundin
2014-04-23 15:43       ` J-P. Rosen
2014-04-23 16:31         ` björn lundin
2014-04-23 16:42           ` J-P. Rosen
2014-04-23 17:51             ` björn lundin
2014-04-23 21:29               ` Pascal Obry
2014-04-23 22:00                 ` J-P. Rosen
2014-04-23 23:48                   ` Shark8
2014-04-24  5:28                     ` J-P. Rosen
2014-04-23 20:11             ` Randy Brukardt
2014-04-23 20:03           ` Randy Brukardt
2014-04-24  9:08             ` björn lundin
2014-04-23 18:02         ` Jeffrey Carter
2014-04-23 20:14           ` Randy Brukardt
2014-04-24  9:16             ` björn lundin
2014-04-24 11:33               ` G.B.
2014-04-24 12:11                 ` björn lundin
2014-04-24 12:32                   ` G.B.
2014-04-23 14:38     ` Dmitry A. Kazakov
2014-04-23 15:46       ` J-P. Rosen
2014-04-23 16:27         ` Dmitry A. Kazakov
2014-04-23 16:40           ` J-P. Rosen
2014-04-23 17:39             ` Dmitry A. Kazakov
2014-04-23 21:40               ` J-P. Rosen
2014-04-24  7:42                 ` Dmitry A. Kazakov
2014-04-24  9:18                   ` J-P. Rosen
2014-04-23 14:06   ` Dmitry A. Kazakov
2014-04-23 14:44     ` björn lundin
2014-04-23 20:28       ` Randy Brukardt
2014-04-24 10:31         ` björn lundin
2014-04-25  1:22           ` Randy Brukardt
2014-04-25  2:19             ` Shark8
2014-04-25  7:31               ` Dmitry A. Kazakov
2014-04-23 14:58     ` björn lundin
2014-04-23 18:05   ` Jeffrey Carter
2014-04-23 19:48   ` Shark8
2014-04-24  9:03     ` G.B.
2014-04-25  1:27       ` 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