comp.lang.ada
 help / color / mirror / Atom feed
From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: Ada is getting more popular!
Date: Sun, 31 Oct 2010 06:02:20 +0100
Date: 2010-10-31T06:02:20+01:00	[thread overview]
Message-ID: <op.vlfb96cfule2fv@garhos> (raw)
In-Reply-To: op.vle2opy9ule2fv@garhos

Le Sun, 31 Oct 2010 02:35:03 +0100, Yannick Duchêne (Hibou57)  
<yannick_duchene@yahoo.fr> a écrit:
> May add classification is more static than composition, or at least,  
> cannot evolve as easily as a construction built upon composition.

About inheritance and polymorphism, which could be kept apart.

Let start with the most popular example : graphic objects.

Le say the graphic object have a position, a bounding rectangle and a  
method to move.

Why should this object be made polymorphic ?

Let say we have a window manager, which needs coordinates and bounding  
rectangle to layout components on a display area.

OK, but does, say, a dialog box, inherit a root type which have an  
abstract Coordinate function and Move procedure ? Wait a minute, the Move  
procedure may not be required to just compute the layout. For this  
process, only the Coordinate and Size functions are needed. Back to the  
question : does the dialog box inherit a type which have Coordinate and  
Size abstract functions ? Is that really the *root* of what a dialog box  
is ? Let return it, and say, the dialog box must provide Coordinate and  
Size functions. This is not the same any more. So why this must be  
polymorph : because many objects of different types must provide the same.  
So what about an access to function ? We would need a way to attach it to  
a context, that is an object. We could give it a parameter, say a dialog  
parameter, but then we would need as many different function type as there  
different object types which must provide Coordinate and Size functions.  
So we may use a tagged type, no to inherit, but instead, just to give the  
Size and Coordinate functions, a context, whose type may vary : we do not  
need to give multiple implementation of Size and Coordinate functions to a  
root object; this is the reverse, we have to provide to one functions,  
multiple context. Technically, this ends to be the same, but logically,  
this is these are both opposite.

So far : Dialog_Box needs to provide Size and Coordinate functions, and  
use a tagged type which can attach similar functions to contexts of  
different types.

Now, after the layout is computed, all these objects need to be moved, so  
these object must now provide a Move procedure. And here, the same kind of  
comments applies as above can apply.

But the ability to provide Size and Coordinate functions is distinct from  
the ability to provide a Move procedure. Why ? Because it is not needed  
for the same reason : the first are required to compute a layout, and the  
second are required if we want to apply that computed layout. We may want  
to compute layouts, without any application of these, as well as we may  
apply precomputed layouts which are not computed by the application at  
runtime.

So, shall we define two root types, one with Size and Coordinate, and  
another with Move ?

Ouch, not good, because this would require multiple inheritance.

So, let do it with simple inheritance : create a root type with Size and  
Coordinate, derive a new type with Move, and derive our object type from  
this latter. But why first Size + Coordinate and then Move ? Why not the  
opposite ? As these are separate requirement, there is no reason why one  
should be made more fundamental than the other.

So let create a root type with Size + Coordinate + Move. But about the  
cases where Move or Size + Coordinate are of strictly no use ?

May an idea would be kind of proxies : define an abstract type with Size +  
Coordinate, another type with Move. Dialog_Box and peers will not inherit  
 from that, but instead will provide a reference to objects of these types,  
as derived types. Let call the first type Positioned and the second one  
Movable. We may have a Dialog_Box which could return a reference to a  
Dialog_Box_Positioned and a Dialog_Box_Movable.

Now, a Dialog_Box is not anymore rooted (so primarily is) at a type which  
have either Move or Size + Coordinate, and is instead what it is : a  
Dialog_Box. From a semantic point of view, this seems more clear to me.  
There is just a dark point : you have to define three type to create a  
Dialog_Box, instead of creating only one (requires longer source) ; but  
still makes more sens, still have a clearer semantic with no arbitrary  
decision (with no justification) as expose above.

This may be a way to formalize a usage of polymorphism which could not be  
confused with classical inheritance. This polymorphism would just be a  
facade to an abstraction, which would require two levels only : an  
abstract type and as many concrete type as needed.

This may be nice to care : when we use tagged types, are we using  
inheritance tree or are we using some facades to some abstractions ?

Could there be some provision to make this two concept explicitly distinct  
in the language ? Something like a keyword which would say : one  
derivation level only for concrete implementation of this abstraction  
allowed ?

But now what if a type would like to reuse part of the implementation of  
Dialog_Box ? It can do it via invokation of standard implementation  
procedure with proper signature which would be visible for both.

Again, but what if we want an Error_Dialog_Box ? Doesn't sound natural to  
say it's particular kind of Dialog_Box ? I have no clear idea for that, as  
I would say yes, this may be legitimately a specialization of a Dialog_Box  
(so we will use classification), ad well an Error_Dialog_Box could simply  
be no more than just a Dialog_Box, with style kind attributes : ex.  
Warning_Style, Error_Style, Information_Style.

This latter is less obvious to me. For all so far, it seems clear to me  
composition offers a clearer semantic, … I am not so sure for the latter.

At least worth to note polymorphism does not implies inheritance hierarchy  
(and thus classification). But how to explicitly render this in source ?  
(I mean render, … something which clearly show the reader the intended  
usage of the polymorphism, and as usual, comments may not be enough here).


-- 
Si les chats miaulent et font autant de vocalises bizarres, c’est pas pour  
les chiens.



  reply	other threads:[~2010-10-31  5:02 UTC|newest]

Thread overview: 128+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-13  7:15 Ada is getting more popular! Nasser M. Abbasi
2010-10-13 12:07 ` ramon_garcia
2010-10-13 14:51   ` Georg Bauhaus
2010-10-13 17:00     ` Dmitry A. Kazakov
2010-10-14 22:10       ` Robert A Duff
2010-10-15  7:27         ` Dmitry A. Kazakov
2010-10-13 15:04   ` Mark Lorenzen
2010-10-13 18:01   ` Jeffrey Carter
2010-10-13 18:50     ` mockturtle
2010-10-13 21:53     ` ramon_garcia
2010-10-13 22:34       ` Vinzent Hoefler
2010-10-13 22:49         ` Nasser M. Abbasi
2010-10-13 23:00           ` ramon_garcia
2010-10-13 23:21             ` Jeffrey Carter
2010-10-14  0:57             ` Georg Bauhaus
2010-10-15 12:12             ` Jacob Sparre Andersen
2010-10-24 22:10               ` Yannick Duchêne (Hibou57)
2010-10-13 22:49         ` ramon_garcia
2010-10-13 23:05           ` Vinzent Hoefler
2010-10-14  4:59             ` Simon Wright
2010-10-14 18:45               ` Vinzent Hoefler
2010-10-14 18:48                 ` Vinzent Hoefler
     [not found]       ` <i95f0n$j61$1@tornado.tornevall.net>
2010-10-14  5:03         ` Simon Wright
2010-10-13 20:17   ` Vinzent Hoefler
2010-10-13 22:05   ` Simon Wright
2010-10-14  2:20   ` tmoran
2010-10-24 22:15     ` Yannick Duchêne (Hibou57)
2010-10-25  0:14       ` Georg Bauhaus
2010-10-24 21:21   ` Yannick Duchêne (Hibou57)
2010-10-25  0:12     ` Georg Bauhaus
2010-10-25  7:43       ` Yannick Duchêne (Hibou57)
2010-10-25  7:52       ` Dmitry A. Kazakov
2010-10-25  8:07         ` Georg Bauhaus
2010-10-25  9:21           ` Dmitry A. Kazakov
2010-10-25  9:47         ` Ludovic Brenta
2010-10-25 10:33           ` Dmitry A. Kazakov
2010-10-25 11:00             ` Ludovic Brenta
2010-10-25 13:24               ` Dmitry A. Kazakov
2010-10-31 19:59                 ` Yannick Duchêne (Hibou57)
2010-10-25 19:06               ` Yannick Duchêne (Hibou57)
2010-10-25 22:39                 ` Thomas Løcke
2010-10-25 23:29                   ` Yannick Duchêne (Hibou57)
2010-10-26  6:29                     ` Thomas Løcke
2010-10-26 14:33                       ` Colin Paul Gloster
2010-10-26 13:59                         ` Dmitry A. Kazakov
2010-10-27 11:59                           ` Colin Paul Gloster
2010-10-27 13:07                             ` Dmitry A. Kazakov
2010-10-27 17:51                               ` Laziness (Was: Re: Ada is getting more popular!) Jeffrey Carter
2010-10-27 20:51                                 ` Yannick Duchêne (Hibou57)
2010-11-03 18:02                               ` Ada is getting more popular! Colin Paul Gloster
2010-11-03 20:52                                 ` Dmitry A. Kazakov
2010-11-04  1:27                                   ` Yannick Duchêne (Hibou57)
2010-11-04  1:30                                 ` Yannick Duchêne (Hibou57)
2010-10-26 18:29                         ` Thomas Løcke
2010-10-27 11:32                           ` Colin Paul Gloster
2010-10-27 19:28                             ` Thomas Løcke
2010-10-27 19:38                               ` Thomas Løcke
2010-10-27 20:46                               ` Yannick Duchêne (Hibou57)
2010-10-28  6:06                                 ` Thomas Løcke
2010-10-28  8:19                                   ` Dmitry A. Kazakov
2010-10-28  9:41                                     ` Thomas Løcke
2010-10-28 13:01                                       ` Dmitry A. Kazakov
2010-10-28 18:21                                         ` Thomas Løcke
2010-10-28 20:18                                           ` Dmitry A. Kazakov
2010-10-28 20:33                                             ` Ludovic Brenta
2010-10-28 21:19                                               ` Dmitry A. Kazakov
2010-10-28 23:37                                                 ` Georg Bauhaus
2010-10-29  8:00                                                   ` Dmitry A. Kazakov
2010-10-29  9:19                                                     ` Georg Bauhaus
2010-10-29 10:03                                                       ` Dmitry A. Kazakov
2010-10-29 16:55                                                       ` Yannick Duchêne (Hibou57)
2010-10-30  9:50                                                       ` Florian Weimer
2010-10-30 12:58                                                         ` Georg Bauhaus
2010-10-30 17:48                                                           ` Florian Weimer
2010-10-30 18:50                                                             ` Yannick Duchêne (Hibou57)
2010-10-30 19:02                                                             ` Georg Bauhaus
2010-10-30 19:26                                                               ` Dmitry A. Kazakov
2010-10-30 20:57                                                                 ` Georg Bauhaus
2010-10-31  7:48                                                                   ` Dmitry A. Kazakov
2010-10-31 10:59                                                                     ` Georg Bauhaus
2010-10-31 12:36                                                                       ` Dmitry A. Kazakov
2010-10-30 18:17                                                           ` Yannick Duchêne (Hibou57)
2010-10-29 16:51                                                     ` Yannick Duchêne (Hibou57)
2010-10-28 21:02                                             ` Thomas Løcke
2010-10-28 21:31                                               ` Dmitry A. Kazakov
2010-10-28 21:28                                           ` Brian Drummond
2010-10-29  5:13                                             ` Thomas Løcke
2010-10-29 14:04                                               ` Brian Drummond
2010-10-29 14:03                                                 ` Thomas Løcke
2010-10-30  6:23                                                   ` Brian Drummond
2010-10-29  0:31                                       ` Chad  R. Meiners
2010-10-29 11:47                                       ` stefan-lucks
2010-10-28 17:25                                     ` Warren
2010-10-28  9:12                                   ` J-P. Rosen
2010-10-28 17:02                                     ` Yannick Duchêne (Hibou57)
2010-10-28 17:58                                     ` Nicholas Collin Paul Gloster
2010-10-28 18:17                                       ` J-P. Rosen
2010-10-29 18:59                                         ` Vinzent Hoefler
2010-10-29 19:56                                           ` Yannick Duchêne (Hibou57)
2010-10-29 20:28                                             ` J-P. Rosen
2010-10-29 21:51                                               ` Yannick Duchêne (Hibou57)
2010-10-31  1:35                                               ` Yannick Duchêne (Hibou57)
2010-10-31  5:02                                                 ` Yannick Duchêne (Hibou57) [this message]
2010-10-31  6:42                                                   ` Yannick Duchêne (Hibou57)
2010-10-31 10:38                                                   ` J-P. Rosen
2010-10-31 10:54                                                     ` Dmitry A. Kazakov
2010-10-31 12:54                                                       ` J-P. Rosen
2010-10-31 14:57                                                         ` Dmitry A. Kazakov
2010-10-31 13:57                                                       ` Niklas Holsti
2010-10-31 21:02                                                         ` Niklas Holsti
2010-11-02  9:15                                                           ` J-P. Rosen
2010-10-31 14:39                                                       ` Yannick Duchêne (Hibou57)
2010-10-31 17:21                                                       ` Jeffrey Carter
2010-10-31 18:04                                                       ` Jeffrey Carter
2010-10-31 20:00                                                         ` Dmitry A. Kazakov
2010-10-31 18:06                                                     ` Jeffrey Carter
2010-10-30  0:01                                             ` Vinzent Hoefler
2010-10-30  0:30                                               ` Yannick Duchêne (Hibou57)
2010-10-30 17:00                                                 ` Vinzent Hoefler
2010-10-26  0:10                   ` Yannick Duchêne (Hibou57)
2010-10-25 12:06             ` Georg Bauhaus
2010-10-25 13:41               ` Dmitry A. Kazakov
2010-10-25 14:55                 ` Georg Bauhaus
2010-10-25 19:33             ` Yannick Duchêne (Hibou57)
2010-10-26 20:37             ` Shark8
2010-10-25 11:49           ` J-P. Rosen
2010-10-25 19:58             ` Yannick Duchêne (Hibou57)
2010-10-25 19:17           ` Yannick Duchêne (Hibou57)
replies disabled

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