comp.lang.ada
 help / color / mirror / Atom feed
* type or subtype?
@ 2002-04-17 12:44 Dmitry A. Kazakov
  2002-04-17 12:50 ` Jean-Marc Bourguet
                   ` (2 more replies)
  0 siblings, 3 replies; 27+ messages in thread
From: Dmitry A. Kazakov @ 2002-04-17 12:44 UTC (permalink / raw)


Hi!

Could somebody explain why tagged type extensions have form:

type X is new Y with ...;

X is rather a subtype of Y than a new type. So why not:

subtype X is Y with ...;

where

type X is new Y with ...;

should mean:

type <anonymous-type> is new Y;
subtype X is <anonymous-type> with ...;

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
  2002-04-17 12:44 Dmitry A. Kazakov
@ 2002-04-17 12:50 ` Jean-Marc Bourguet
  2002-04-17 13:55   ` Dmitry A. Kazakov
  2002-04-18  4:29 ` Richard Riehle
  2002-04-18  4:48 ` Robert Dewar
  2 siblings, 1 reply; 27+ messages in thread
From: Jean-Marc Bourguet @ 2002-04-17 12:50 UTC (permalink / raw)


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

> Hi!
> 
> Could somebody explain why tagged type extensions have form:
> 
> type X is new Y with ...;
> 
> X is rather a subtype of Y than a new type. 

I don't agree.  All X are not Y, something which is true for subtypes
(which are a type with a constraint for ada).

Yours,

-- 
Jean-Marc



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
  2002-04-17 12:50 ` Jean-Marc Bourguet
@ 2002-04-17 13:55   ` Dmitry A. Kazakov
  2002-04-17 14:10     ` Jean-Marc Bourguet
  0 siblings, 1 reply; 27+ messages in thread
From: Dmitry A. Kazakov @ 2002-04-17 13:55 UTC (permalink / raw)


On 17 Apr 2002 14:50:45 +0200, Jean-Marc Bourguet <jm@bourguet.org>
wrote:

>Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> writes:
>
>> Could somebody explain why tagged type extensions have form:
>> 
>> type X is new Y with ...;
>> 
>> X is rather a subtype of Y than a new type. 
>
>I don't agree.  All X are not Y, something which is true for subtypes
>(which are a type with a constraint for ada).

Which meaning has "are" here. There could be many:

1.  X is substitutable for Y [a LSP subtype]
2. X inherits representation of Y [an OO-ish subclass]
3. There is an implicit conversion from X to Y and back.

BTW

a. Is it true that all X are X'Class?
b. Isn't all type X is new Y with null record; are Y?

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
  2002-04-17 13:55   ` Dmitry A. Kazakov
@ 2002-04-17 14:10     ` Jean-Marc Bourguet
  2002-04-18  4:50       ` Robert Dewar
  2002-04-18  7:34       ` Dmitry A. Kazakov
  0 siblings, 2 replies; 27+ messages in thread
From: Jean-Marc Bourguet @ 2002-04-17 14:10 UTC (permalink / raw)


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

> On 17 Apr 2002 14:50:45 +0200, Jean-Marc Bourguet <jm@bourguet.org>
> wrote:
> 
> >Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> writes:
> >
> >> Could somebody explain why tagged type extensions have form:
> >> 
> >> type X is new Y with ...;
> >> 
> >> X is rather a subtype of Y than a new type. 
> >
> >I don't agree.  All X are not Y, something which is true for subtypes
> >(which are a type with a constraint for ada).
> 
> Which meaning has "are" here. 

> There could be many:
> 
> 1.  X is substitutable for Y [a LSP subtype]
> 2. X inherits representation of Y [an OO-ish subclass]
> 3. There is an implicit conversion from X to Y and back.

What I meant is all values of X are values of Y.

Definition according to the standard
(http://www.ada-auth.org/~acats/arm-html/RM-3-2.html) and not
according some type theory.

    A subtype of a given type is a combination of the type, a
    constraint on values of the type, and certain attributes specific
    to the subtype.

> 
> BTW
> 
> a. Is it true that all X are X'Class?

Yes.

> b. Isn't all type X is new Y with null record; are Y?

No (the tag is part of the value).

Yours,

-- 
Jean-Marc



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
  2002-04-17 12:44 Dmitry A. Kazakov
  2002-04-17 12:50 ` Jean-Marc Bourguet
@ 2002-04-18  4:29 ` Richard Riehle
  2002-04-18  7:51   ` Dmitry A. Kazakov
  2002-04-18  4:48 ` Robert Dewar
  2 siblings, 1 reply; 27+ messages in thread
From: Richard Riehle @ 2002-04-18  4:29 UTC (permalink / raw)


"Dmitry A. Kazakov" wrote:

> Hi!
>
> Could somebody explain why tagged type extensions have form:
>
> type X is new Y with ...;
>
> X is rather a subtype of Y than a new type. So why not:
>
> subtype X is Y with ...;
>
> where
>
> type X is new Y with ...;

In Ada, a type can be characterized as:

                    1)  Has a type identifier
                    2)  Has a set of operations
                    3)  Has a set of values
                    4)  Has a wall between itself and other types.

A subtype, when using the reserved word subtype, defines all
of the above except for number 4.   There is no "wall" between
a subtype and its parent type, or a subtype and its siblings/cousins.
It still has a wall between itself and other fully-defined types,
including types derived from the parent.

It is important to keep the wall between a tagged type and its
derivations so mechanisms such as overriding and dispatching
can work properly.

Richard Riehle






^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
  2002-04-17 12:44 Dmitry A. Kazakov
  2002-04-17 12:50 ` Jean-Marc Bourguet
  2002-04-18  4:29 ` Richard Riehle
@ 2002-04-18  4:48 ` Robert Dewar
  2002-04-18  8:17   ` Dmitry A. Kazakov
  2 siblings, 1 reply; 27+ messages in thread
From: Robert Dewar @ 2002-04-18  4:48 UTC (permalink / raw)


Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote in message news:<h6qqbucpffqbmapncancnq0l7qp2qpn1ui@4ax.com>...

> Hi!
> 
> Could somebody explain why tagged type extensions have form:
> 
> type X is new Y with ...;
> 
> X is rather a subtype of Y than a new type. So why not:

You are simply getting confused by terminology. Subtype in Ada
does not mean what subtype in some other languages means.

Just consider, obviously if Y is extended from X, then it must
be possible to define two separate procedures Draw that take
resp a Y and an X parameter, but equally obviously, if X and
Y were subtypes in the Ada sense, you could not do this.

C++ is not a helpful analogy here, since there are no subtypes
in the Ada sense in C++.

Whenever you come to a new language, you have to absorb its
terminology, and that can sometimes lead to confusion early on.
Once you are familiar with Ada, and know what subtype means 
*in Ada* then you will see that the Ada scheme is consistent
and makes sense.



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
  2002-04-17 14:10     ` Jean-Marc Bourguet
@ 2002-04-18  4:50       ` Robert Dewar
  2002-04-18  7:34       ` Dmitry A. Kazakov
  1 sibling, 0 replies; 27+ messages in thread
From: Robert Dewar @ 2002-04-18  4:50 UTC (permalink / raw)


Jean-Marc Bourguet <jm@bourguet.org> wrote in message news:<3cbd8267@news.cadence.com>...

> No (the tag is part of the value).

Actually that's not true. You don't get into too much trouble making
this wrong assumption, but you definitely will find some things awkward
to understand if you start with this incorrect definition.



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
  2002-04-17 14:10     ` Jean-Marc Bourguet
  2002-04-18  4:50       ` Robert Dewar
@ 2002-04-18  7:34       ` Dmitry A. Kazakov
  1 sibling, 0 replies; 27+ messages in thread
From: Dmitry A. Kazakov @ 2002-04-18  7:34 UTC (permalink / raw)


On 17 Apr 2002 16:10:38 +0200, Jean-Marc Bourguet <jm@bourguet.org>
wrote:

>Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> writes:
>
>> On 17 Apr 2002 14:50:45 +0200, Jean-Marc Bourguet <jm@bourguet.org>
>> wrote:
>> 
>> >Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> writes:
>> >
>> >> Could somebody explain why tagged type extensions have form:
>> >> 
>> >> type X is new Y with ...;
>> >> 
>> >> X is rather a subtype of Y than a new type. 
>> >
>> >I don't agree.  All X are not Y, something which is true for subtypes
>> >(which are a type with a constraint for ada).
>> 
>> Which meaning has "are" here. 
>
>> There could be many:
>> 
>> 1.  X is substitutable for Y [a LSP subtype]
>> 2. X inherits representation of Y [an OO-ish subclass]
>> 3. There is an implicit conversion from X to Y and back.
>
>What I meant is all values of X are values of Y.
>
>Definition according to the standard
>(http://www.ada-auth.org/~acats/arm-html/RM-3-2.html) and not
>according some type theory.
>
>    A subtype of a given type is a combination of the type, a
>    constraint on values of the type, and certain attributes specific
>    to the subtype.

This definition fits extended types very well. An extended type
inherits the base type representation [contains it as a part], may
constrain the base [through its discriminants], has certain attributes
of its own [the extension]

>> BTW
>> 
>> a. Is it true that all X are X'Class?
>
>Yes.

So one could assume:

subtype X is X'Class (Tag => <some constraint>);

>> b. Isn't all type X is new Y with null record; are Y?
>
>No (the tag is part of the value).

Firstly, it is an implementation detail [RM does not require that
explicitly]. BTW, this why any definition of [sub]type based on values
is bad, because it would inevitable expose value representation.

Secondly, speaking about tags an thus about class wide values, both
instances of X'Class and Y'Class have tags. The only difference is
that values of the tags are different.

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
  2002-04-18  4:29 ` Richard Riehle
@ 2002-04-18  7:51   ` Dmitry A. Kazakov
  0 siblings, 0 replies; 27+ messages in thread
From: Dmitry A. Kazakov @ 2002-04-18  7:51 UTC (permalink / raw)


On Wed, 17 Apr 2002 21:29:59 -0700, Richard Riehle
<richard@adaworks.com> wrote:

>"Dmitry A. Kazakov" wrote:
>
>> Hi!
>>
>> Could somebody explain why tagged type extensions have form:
>>
>> type X is new Y with ...;
>>
>> X is rather a subtype of Y than a new type. So why not:
>>
>> subtype X is Y with ...;
>>
>> where
>>
>> type X is new Y with ...;
>
>In Ada, a type can be characterized as:
>
>                    1)  Has a type identifier
>                    2)  Has a set of operations
>                    3)  Has a set of values
>                    4)  Has a wall between itself and other types.
>
>A subtype, when using the reserved word subtype, defines all
>of the above except for number 4.   There is no "wall" between
>a subtype and its parent type, or a subtype and its siblings/cousins.
>It still has a wall between itself and other fully-defined types,
>including types derived from the parent.

There is no solid wall between X and Y or between X and Y'Class. So 4
is not well applied to the case. This is why I am so curious about the
rationale behind this syntax. Another thing is that it has a nasty
consequence:

   type X is tagged null record;
   type Y is new X; -- Illegal

We cannot clone the type X in Ada 83 sense. Maybe it is not a big loss
[however I believe it is], but it is definitely an irregularity.

>It is important to keep the wall between a tagged type and its
>derivations so mechanisms such as overriding and dispatching
>can work properly.

It is not a wall, it is rather a membrane. IMO it is closer to

subtype Name is String (1..20);

You can "convert" Name to String, but not every String can be
"converted" to Name.

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
  2002-04-18  4:48 ` Robert Dewar
@ 2002-04-18  8:17   ` Dmitry A. Kazakov
  2002-04-19 11:52     ` Robert Dewar
  2002-04-19 11:54     ` Robert Dewar
  0 siblings, 2 replies; 27+ messages in thread
From: Dmitry A. Kazakov @ 2002-04-18  8:17 UTC (permalink / raw)


On 17 Apr 2002 21:48:26 -0700, dewar@gnat.com (Robert Dewar) wrote:

>Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote in message news:<h6qqbucpffqbmapncancnq0l7qp2qpn1ui@4ax.com>...
>
>> Hi!
>> 
>> Could somebody explain why tagged type extensions have form:
>> 
>> type X is new Y with ...;
>> 
>> X is rather a subtype of Y than a new type. So why not:
>
>You are simply getting confused by terminology. Subtype in Ada
>does not mean what subtype in some other languages means.
>
>Just consider, obviously if Y is extended from X, then it must
>be possible to define two separate procedures Draw that take
>resp a Y and an X parameter,

These two Draws are not separate, because Y is an extension of X. Thus
it is not an overloading [which would be conflicting], but overriding.
Both Draws are the implementation of a *single* polymorphic
[dispatching] Draw defined on Y'Class.

> but equally obviously, if X and
>Y were subtypes in the Ada sense, you could not do this.

In the Ada 83 sense?

>C++ is not a helpful analogy here, since there are no subtypes
>in the Ada sense in C++.

Maybe, however

   typedef int My_Int;

much resembles

   subtype My_Int is int;

But, why should I care of C++?

>Whenever you come to a new language, you have to absorb its
>terminology, and that can sometimes lead to confusion early on.
>Once you are familiar with Ada, and know what subtype means 
>*in Ada* then you will see that the Ada scheme is consistent
>and makes sense.

Should that imply that there is only one consistent and making sense
scheme?

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
  2002-04-18  8:17   ` Dmitry A. Kazakov
@ 2002-04-19 11:52     ` Robert Dewar
  2002-04-22  7:33       ` Dmitry A. Kazakov
  2002-04-19 11:54     ` Robert Dewar
  1 sibling, 1 reply; 27+ messages in thread
From: Robert Dewar @ 2002-04-19 11:52 UTC (permalink / raw)


Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote in message news:<4rusbugcvdopaqvf54bc7q73tsin9lvg12@4ax.com>...
> On 17 Apr 2002 21:48:26 -0700, dewar@gnat.com (Robert Dewar) wrote:
> 
> These two Draws are not separate, because Y is an extension of X. Thus
> it is not an overloading [which would be conflicting], but overriding.
> Both Draws are the implementation of a *single* polymorphic
> [dispatching] Draw defined on Y'Class.

No, that's wrong, it is an overloading. You have not quite grocked
the Ada model yet :-)

Try reading the rationale.



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
  2002-04-18  8:17   ` Dmitry A. Kazakov
  2002-04-19 11:52     ` Robert Dewar
@ 2002-04-19 11:54     ` Robert Dewar
  2002-04-22  7:58       ` Dmitry A. Kazakov
  1 sibling, 1 reply; 27+ messages in thread
From: Robert Dewar @ 2002-04-19 11:54 UTC (permalink / raw)


Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote in message news:<4rusbugcvdopaqvf54bc7q73tsin9lvg12@4ax.com>...

> Should that imply that there is only one consistent and making sense
> scheme?

Not at all, see for example Norm Cohen's proposal for doing object
oriented extension with subtypes.

But you need to first understand the model that is in place (you don't
yet), then you can start considering alternatives, and you should be
able to understand why Tuck's derived type proposal immediately won
favor over the subtype proposal (for many many reasons).



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
  2002-04-19 11:52     ` Robert Dewar
@ 2002-04-22  7:33       ` Dmitry A. Kazakov
  0 siblings, 0 replies; 27+ messages in thread
From: Dmitry A. Kazakov @ 2002-04-22  7:33 UTC (permalink / raw)


On 19 Apr 2002 04:52:50 -0700, dewar@gnat.com (Robert Dewar) wrote:

>Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote in message news:<4rusbugcvdopaqvf54bc7q73tsin9lvg12@4ax.com>...
>> On 17 Apr 2002 21:48:26 -0700, dewar@gnat.com (Robert Dewar) wrote:
>> 
>> These two Draws are not separate, because Y is an extension of X. Thus
>> it is not an overloading [which would be conflicting], but overriding.
>> Both Draws are the implementation of a *single* polymorphic
>> [dispatching] Draw defined on Y'Class.

Sorry, typo error, should be X'Class.

>No, that's wrong, it is an overloading. You have not quite grocked
>the Ada model yet :-)

type X is tagged ...
procedure Draw (A : X);

type Y is new X with ...
procedure Draw (A : Y);

Is that overloading?

Are these two procedures separate? My point is that they are not.

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
  2002-04-19 11:54     ` Robert Dewar
@ 2002-04-22  7:58       ` Dmitry A. Kazakov
  2002-04-22 13:39         ` Robert Dewar
  0 siblings, 1 reply; 27+ messages in thread
From: Dmitry A. Kazakov @ 2002-04-22  7:58 UTC (permalink / raw)


On 19 Apr 2002 04:54:47 -0700, dewar@gnat.com (Robert Dewar) wrote:

>Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote in message news:<4rusbugcvdopaqvf54bc7q73tsin9lvg12@4ax.com>...
>
>> Should that imply that there is only one consistent and making sense
>> scheme?
>
>Not at all, see for example Norm Cohen's proposal for doing object
>oriented extension with subtypes.
>
>But you need to first understand the model that is in place (you don't
>yet), then you can start considering alternatives, and you should be
>able to understand why Tuck's derived type proposal immediately won
>favor over the subtype proposal (for many many reasons).

The question was not about the type model. [However, subclassing using
only type extensions is badly limited per se]. The question was, why
the word "type" was chosen instead of "subtype".

   type Y is new X with ...;

has nothing in common and moreover conflicts with

   type Y is new X;

So, where is the consistence?

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
@ 2002-04-22  8:14 Grein, Christoph
  2002-04-22 11:36 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 27+ messages in thread
From: Grein, Christoph @ 2002-04-22  8:14 UTC (permalink / raw)


> >No, that's wrong, it is an overloading. You have not quite grocked
> >the Ada model yet :-)
> 
> type X is tagged ...
> procedure Draw (A : X);
> 
> type Y is new X with ...
> procedure Draw (A : Y);
> 
> Is that overloading?
> 
> Are these two procedures separate? My point is that they are not.
> 

I_definitely_call_this_Overloading:
declare
  My_X: X;
  My_Y: Y;
begin
  Draw (My_X);
  Draw (My_Y);
end I_definitely_call_this_Overloading;

Your procedure Draw (A : Y) overrides the inherited Draw. The inherited 
operation is defined as:

procedure Draw (A : Y) is
begin
  Draw (X (A));
end Draw;

Thus Draw (A : X) and Draw (A : Y) are overloading each other.



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
@ 2002-04-22  8:34 Grein, Christoph
  2002-04-22 11:49 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 27+ messages in thread
From: Grein, Christoph @ 2002-04-22  8:34 UTC (permalink / raw)


> ...The question was, why
> the word "type" was chosen instead of "subtype".
> 
>    type Y is new X with ...;
> 
> has nothing in common and moreover conflicts with
> 
>    type Y is new X;
> 
> So, where is the consistence?

There is different syntax for deriving from non-tagged or from tagged types.

Non-tagged types cannot be extended upon derivation, so you have to use the 
second form.

Tagged types are extended, so you have to use the first form. Even if you do not 
want to extend:

   type Y is new X with null record;

So Y is defnitely no subtype of X, and operations on Y inherited from X overload 
the operations on X, whether you override them or not (see my other post).



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
  2002-04-22  8:14 Grein, Christoph
@ 2002-04-22 11:36 ` Dmitry A. Kazakov
  0 siblings, 0 replies; 27+ messages in thread
From: Dmitry A. Kazakov @ 2002-04-22 11:36 UTC (permalink / raw)


On Mon, 22 Apr 2002 10:14:10 +0200 (MET DST), "Grein, Christoph"
<christoph.grein@eurocopter.com> wrote:

>> >No, that's wrong, it is an overloading. You have not quite grocked
>> >the Ada model yet :-)
>> 
>> type X is tagged ...
>> procedure Draw (A : X);
>> 
>> type Y is new X with ...
>> procedure Draw (A : Y);
>> 
>> Is that overloading?
>> 
>> Are these two procedures separate? My point is that they are not.
>
>I_definitely_call_this_Overloading:
>declare
>  My_X: X;
>  My_Y: Y;
>begin
>  Draw (My_X);
>  Draw (My_Y);
>end I_definitely_call_this_Overloading;
>
>Your procedure Draw (A : Y) overrides the inherited Draw. The inherited 
>operation is defined as:
>
>procedure Draw (A : Y) is
>begin
>  Draw (X (A));
>end Draw;
>
>Thus Draw (A : X) and Draw (A : Y) are overloading each other.

This does not change neither the fact that it is overriding of *a
primitive operation Draw* nor that both procedures are not separate.

Yes, the *name Draw* could be occasionally overloaded in some
contexts. It could be as well not. Consider:

1. Public overriding a private primitive operation:

package XX is
   type X is tagged null record;
private
   procedure Draw (A : X); -- Invisible in public contexts
end XX;

with XX; use XX;
package YY is
   type Y is new X with null record;
   procedure Draw (A : Y);
end YY;

2. Overriding an abstract primitive operation:

type X is abstract tagged ...
procedure Draw (A : X) is abstract; -- Doesn't exist

type Y is new X with ...
procedure Draw (A : Y);

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
  2002-04-22  8:34 type or subtype? Grein, Christoph
@ 2002-04-22 11:49 ` Dmitry A. Kazakov
  0 siblings, 0 replies; 27+ messages in thread
From: Dmitry A. Kazakov @ 2002-04-22 11:49 UTC (permalink / raw)


On Mon, 22 Apr 2002 10:34:38 +0200 (MET DST), "Grein, Christoph"
<christoph.grein@eurocopter.com> wrote:

>> ...The question was, why
>> the word "type" was chosen instead of "subtype".
>> 
>>    type Y is new X with ...;
>> 
>> has nothing in common and moreover conflicts with
>> 
>>    type Y is new X;
>> 
>> So, where is the consistence?
>
>There is different syntax for deriving from non-tagged or from tagged types.
>
>Non-tagged types cannot be extended upon derivation, so you have to use the 
>second form.
>
>Tagged types are extended, so you have to use the first form. Even if you do not 
>want to extend:
>
>   type Y is new X with null record;

This is by no means an equivalent of

   type Y is new X;

It is an absolutely different thing. Consider:

   type Numbers is  ...
   type Apples is new Numbers;
   type Oranges is new Numbers;

and 

   type Numbers is tagged  ...
   type Apples is new Numbers with null record;
   type Oranges is new Numbers with null record;

It could be argued that little is lost because of missing [proper]
multiple dispatch in Ada. But one (should I say mistake?) does not
excuse other.

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
@ 2002-04-22 13:09 Grein, Christoph
  2002-04-22 13:58 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 27+ messages in thread
From: Grein, Christoph @ 2002-04-22 13:09 UTC (permalink / raw)


> From: "Dmitry A.Kazakov" <mailbox@dmitry-kazakov.de>
> 
> On Mon, 22 Apr 2002 10:34:38 +0200 (MET DST), "Grein, Christoph"
> <christoph.grein@eurocopter.com> wrote:
> 
> >> ...The question was, why
> >> the word "type" was chosen instead of "subtype".
> >> 
> >>    type Y is new X with ...;
> >> 
> >> has nothing in common and moreover conflicts with
> >> 
> >>    type Y is new X;
> >> 
> >> So, where is the consistence?
> >
> >There is different syntax for deriving from non-tagged or from tagged types.
> >
> >Non-tagged types cannot be extended upon derivation, so you have to use the 
> >second form.
> >
> >Tagged types are extended, so you have to use the first form. Even if you do 
not 
> >want to extend:
> >
> >   type Y is new X with null record;
> 
> This is by no means an equivalent of
> 
>    type Y is new X;

I didn't claim that this was equivalent, on the contrary!

> It is an absolutely different thing. Consider:
> 
>    type Numbers is  ...
>    type Apples is new Numbers;
>    type Oranges is new Numbers;
> 
> and 
> 
>    type Numbers is tagged  ...
>    type Apples is new Numbers with null record;
>    type Oranges is new Numbers with null record;
> 
> It could be argued that little is lost because of missing [proper]
> multiple dispatch in Ada. But one (should I say mistake?) does not
> excuse other.

What are you about to say here? I know well the difference. Where's the
(missing) multiple dispatch that could come into the picture here?

What has this to do with your original question type vs. subtype?



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
@ 2002-04-22 13:18 Grein, Christoph
  2002-04-22 15:01 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 27+ messages in thread
From: Grein, Christoph @ 2002-04-22 13:18 UTC (permalink / raw)


> From: "Dmitry A.Kazakov" <mailbox@dmitry-kazakov.de>
> On Mon, 22 Apr 2002 10:14:10 +0200 (MET DST), "Grein, Christoph"
> <christoph.grein@eurocopter.com> wrote:
> 
> >> >No, that's wrong, it is an overloading. You have not quite grocked
> >> >the Ada model yet :-)
> >> 
> >> type X is tagged ...
> >> procedure Draw (A : X);
> >> 
> >> type Y is new X with ...
> >> procedure Draw (A : Y);
> >> 
> >> Is that overloading?
> >> 
> >> Are these two procedures separate? My point is that they are not.
> >
> >I_definitely_call_this_Overloading:
> >declare
> >  My_X: X;
> >  My_Y: Y;
> >begin
> >  Draw (My_X);
> >  Draw (My_Y);
> >end I_definitely_call_this_Overloading;
> >
> >Your procedure Draw (A : Y) overrides the inherited Draw. The inherited 
> >operation is defined as:
> >
> >procedure Draw (A : Y) is
> >begin
> >  Draw (X (A));
> >end Draw;
> >
> >Thus Draw (A : X) and Draw (A : Y) are overloading each other.
> 
> This does not change neither the fact that it is overriding of *a
> primitive operation Draw* nor that both procedures are not separate.

I did not deny that it overrides. But they also overload. Please see again above 
I_definitely_call_this_Overloading (in this block, it is quite irrelevant that X 
and Y are related; if you replace X and Y by Integer and Boolean e.g. that would 
not change anything - and you would not deny that this is overloading, or would 
you?). This shows that both Draws are separate (whatever you might mean with 
this non-technical Ada term).

In Ada terms, there is an entry in the dispatch table for both Draw operations, 
one for each type in the derivation tree.

In the light of the above, I cannot see what you are going to say below.

> Yes, the *name Draw* could be occasionally overloaded in some
> contexts. It could be as well not. Consider:
> 
> 1. Public overriding a private primitive operation:
> 
> package XX is
>    type X is tagged null record;
> private
>    procedure Draw (A : X); -- Invisible in public contexts
> end XX;
> 
> with XX; use XX;
> package YY is
>    type Y is new X with null record;
>    procedure Draw (A : Y);
> end YY;
> 
> 2. Overriding an abstract primitive operation:
> 
> type X is abstract tagged ...
> procedure Draw (A : X) is abstract; -- Doesn't exist
> 
> type Y is new X with ...
> procedure Draw (A : Y);
> 
> ---
> Regards,
> Dmitry Kazakov
> www.dmitry-kazakov.de
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
  2002-04-22  7:58       ` Dmitry A. Kazakov
@ 2002-04-22 13:39         ` Robert Dewar
  2002-04-22 14:41           ` Dmitry A. Kazakov
  0 siblings, 1 reply; 27+ messages in thread
From: Robert Dewar @ 2002-04-22 13:39 UTC (permalink / raw)


Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote in message news:<0bf7cu00githt3atlt97f67ev3dkoolfh4@4ax.com>...
> The question was not about the type model. [However, subclassing using
> only type extensions is badly limited per se].

I don't think so, if you think it is badly limited, you still don't
understand the model, since for example, it is (if we stick to single
inheritance and that is of course another dimension of discussion
entirely) more flexible and less limited than the model of C++
(consider the issue of deriving dyadic operations cleanly for
example).

> The question was, why
> the word "type" was chosen instead of "subtype".
> 
>    type Y is new X with ...;
> 
> has nothing in common and moreover conflicts with
> 
>    type Y is new X;
> 
> So, where is the consistence?

No, there is no conflict here. In fact the clever idea in Tuck's
proposal
was precisely to realize that these are consistent usages. Once again
I
refer you to the rationale (sounds like you have not read it, and you
will
find much more coherent discussion there than you will get from random
threads in CLA :-) Also this has been discussed extensively. Now that
google has the archives there is no excuse for not going and looking
them up before
starting a redundant thread.
> 
> ---
> Regards,
> Dmitry Kazakov
> www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
  2002-04-22 13:09 Grein, Christoph
@ 2002-04-22 13:58 ` Dmitry A. Kazakov
  0 siblings, 0 replies; 27+ messages in thread
From: Dmitry A. Kazakov @ 2002-04-22 13:58 UTC (permalink / raw)


On Mon, 22 Apr 2002 15:09:24 +0200 (MET DST), "Grein, Christoph"
<christoph.grein@eurocopter.com> wrote:

>> From: "Dmitry A.Kazakov" <mailbox@dmitry-kazakov.de>
>> 
>> On Mon, 22 Apr 2002 10:34:38 +0200 (MET DST), "Grein, Christoph"
>> <christoph.grein@eurocopter.com> wrote:
>> 
>> >Tagged types are extended, so you have to use the first form. Even if you do 
>not 
>> >want to extend:
>> >
>> >   type Y is new X with null record;
>> 
>> This is by no means an equivalent of
>> 
>>    type Y is new X;
>
>I didn't claim that this was equivalent, on the contrary!

Then you should understand why I am wondering why the form "type Y is
new X with" was chosen.

>> It is an absolutely different thing. Consider:
>> 
>>    type Numbers is  ...
>>    type Apples is new Numbers;
>>    type Oranges is new Numbers;
>> 
>> and 
>> 
>>    type Numbers is tagged  ...
>>    type Apples is new Numbers with null record;
>>    type Oranges is new Numbers with null record;
>> 
>> It could be argued that little is lost because of missing [proper]
>> multiple dispatch in Ada. But one (should I say mistake?) does not
>> excuse other.
>
>What are you about to say here? I know well the difference. Where's the
>(missing) multiple dispatch

It is not completely missing. It is present but limited by arguments
having same tags [implied of same class].

> that could come into the picture here?

Because of the limitation (see above). If you define a dyadic
operation on Number, you will probably have no big problem when Apples
and Oranges get mixed. It is illegal due to the limitation. [Yet bad
enough that it is in worst case checked at run time, while for
non-tagged type it is checked at compile time]. But if full multiple
dispatch were supported, that could be a problem, because a useful
ability to clone types is lost for tagged ones.

>What has this to do with your original question type vs. subtype?

I want my type X is new Y; back! (:-))

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
  2002-04-22 13:39         ` Robert Dewar
@ 2002-04-22 14:41           ` Dmitry A. Kazakov
  0 siblings, 0 replies; 27+ messages in thread
From: Dmitry A. Kazakov @ 2002-04-22 14:41 UTC (permalink / raw)


On 22 Apr 2002 06:39:11 -0700, dewar@gnat.com (Robert Dewar) wrote:

>Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote in message news:<0bf7cu00githt3atlt97f67ev3dkoolfh4@4ax.com>...
>> The question was not about the type model. [However, subclassing using
>> only type extensions is badly limited per se].
>
>I don't think so, if you think it is badly limited, you still don't
>understand the model, since for example, it is (if we stick to single
>inheritance and that is of course another dimension of discussion
>entirely) more flexible and less limited than the model of C++
>(consider the issue of deriving dyadic operations cleanly for
>example).

C++ has same model. Multiple inheritance is not an issue here. Type
extension means that the derived type contains the base as a part. In
this sense C++ uses a similar type model.

It is limiting because one could wish to completely replace the
implementation of the base type. For instance, when Circle is derived
from Ellipse.

>> The question was, why
>> the word "type" was chosen instead of "subtype".
>> 
>>    type Y is new X with ...;
>> 
>> has nothing in common and moreover conflicts with
>> 
>>    type Y is new X;
>> 
>> So, where is the consistence?
>
>No, there is no conflict here.

Fine, we disagree here.

>In fact the clever idea in Tuck's
>proposal
>was precisely to realize that these are consistent usages. Once again
>I refer you to the rationale (sounds like you have not read it, and you
>will find much more coherent discussion there than you will get from random
>threads in CLA :-)

I know, that you dislike c.l.a! (:-))

>Also this has been discussed extensively. Now that
>google has the archives there is no excuse for not going and looking
>them up before starting a redundant thread.

Redundancy is a way to improve safety (:-))

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
  2002-04-22 13:18 Grein, Christoph
@ 2002-04-22 15:01 ` Dmitry A. Kazakov
  2002-04-23  0:01   ` Robert Dewar
  0 siblings, 1 reply; 27+ messages in thread
From: Dmitry A. Kazakov @ 2002-04-22 15:01 UTC (permalink / raw)


On Mon, 22 Apr 2002 15:18:26 +0200 (MET DST), "Grein, Christoph"
<christoph.grein@eurocopter.com> wrote:

>> From: "Dmitry A.Kazakov" <mailbox@dmitry-kazakov.de>
>> On Mon, 22 Apr 2002 10:14:10 +0200 (MET DST), "Grein, Christoph"
>> <christoph.grein@eurocopter.com> wrote:
>> 
>> >> >No, that's wrong, it is an overloading. You have not quite grocked
>> >> >the Ada model yet :-)
>> >> 
>> >> type X is tagged ...
>> >> procedure Draw (A : X);
>> >> 
>> >> type Y is new X with ...
>> >> procedure Draw (A : Y);
>> >> 
>> >> Is that overloading?
>> >> 
>> >> Are these two procedures separate? My point is that they are not.
>> >
>> >I_definitely_call_this_Overloading:
>> >declare
>> >  My_X: X;
>> >  My_Y: Y;
>> >begin
>> >  Draw (My_X);
>> >  Draw (My_Y);
>> >end I_definitely_call_this_Overloading;
>> >
>> >Your procedure Draw (A : Y) overrides the inherited Draw. The inherited 
>> >operation is defined as:
>> >
>> >procedure Draw (A : Y) is
>> >begin
>> >  Draw (X (A));
>> >end Draw;
>> >
>> >Thus Draw (A : X) and Draw (A : Y) are overloading each other.
>> 
>> This does not change neither the fact that it is overriding of *a
>> primitive operation Draw* nor that both procedures are not separate.
>
>I did not deny that it overrides. But they also overload. Please see again above 
>I_definitely_call_this_Overloading (in this block, it is quite irrelevant that X 
>and Y are related; if you replace X and Y by Integer and Boolean e.g. that would 
>not change anything

That would change that it will no more override.

> - and you would not deny that this is overloading, or would 
>you?).

I do not deny that it can be overloaded as any other subprogram. I
deny only that overriding is overloading.

--
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
  2002-04-22 15:01 ` Dmitry A. Kazakov
@ 2002-04-23  0:01   ` Robert Dewar
  0 siblings, 0 replies; 27+ messages in thread
From: Robert Dewar @ 2002-04-23  0:01 UTC (permalink / raw)


Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote in message news:<oe88cu4js259fbd6466t8ildt3frsalkvv@4ax.com>...
> I do not deny that it can be overloaded as any other
> subprogram. I deny only that overriding is overloading.

Well you can certainly behave like Humpty-Dumpty in Alice (*) but it
is usually better to adopt standard terminology
if you want to be understood by others.

In Ada, overriding is a particular form of overloading, so
if you don't want to use the term overloading the way Ada
does, then fine, but people will get confused by your odd
use of the term.

(*) If you don't know the reference, it's a significant
cultural gap for those who read and write english. I
refer you to the source :-)



^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
@ 2002-04-23  1:42 Alexandre E. Kopilovitch
  0 siblings, 0 replies; 27+ messages in thread
From: Alexandre E. Kopilovitch @ 2002-04-23  1:42 UTC (permalink / raw)


dewar@gnat.com (Robert Dewar) wrote:
>Humpty-Dumpty in Alice (*)
>...
>(*) If you don't know the reference, it's a significant
>cultural gap for those who read and write english.

Being quite experienced in enduring that cultural gap (or rather, barrier),
I'd like to say that:

1) although I have read Alice several times both in English and in Russian
translation (in fact, I have read even Sylvie and Bruno -:) and vaguely remember
Humpty-Dumpty (by the way, it translates as Shaltai-Boltai in Russian -:),
I can't justify the reference. For me, the most important feature of Humpty-Dumpty
is that he was sitting on the wall, and then all King's men failed to put his
pieces together...

2) there is more subtle, but sometimes significant thing, you may be not aware
of it: one may be able to read and write, but not to speak or understand a speech,
that is, s/he may be not aware of "phonetic life".


Alexander Kopilovitch                      aek@vib.usr.pu.ru
Saint-Petersburg
Russia




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: type or subtype?
@ 2002-04-24  5:27 Grein, Christoph
  0 siblings, 0 replies; 27+ messages in thread
From: Grein, Christoph @ 2002-04-24  5:27 UTC (permalink / raw)


> From: "Dmitry A.Kazakov" <mailbox@dmitry-kazakov.de>
> 
> Then you should understand why I am wondering why the form "type Y is
> new X with" was chosen.
> ... [snip]
> 
> I want my type X is new Y; back! (:-))
> 

OK, I give up on this fruitless thread. You either do not want to understand or 
there is some model in your mind that prevents you from understanding...

Believe it or like it or not - type X is new Y with ... does _not_ define a 
subtype and operations overload as well as override.

--------------------------
> On 22 Apr 2002 06:39:11 -0700, dewar@gnat.com (Robert Dewar) wrote:
> ... [snip]
> 
> >> The question was, why
> >> the word "type" was chosen instead of "subtype".
> >> 
> >>    type Y is new X with ...;
> >> 
> >> has nothing in common and moreover conflicts with
> >> 
> >>    type Y is new X;
> >> 
> >> So, where is the consistence?
> >
> >No, there is no conflict here.
> 
> Fine, we disagree here.
> >In fact the clever idea in Tuck's
> >proposal
> >was precisely to realize that these are consistent usages. Once again
> >I refer you to the rationale (sounds like you have not read it, and you
> >will find much more coherent discussion there than you will get from random
> >threads in CLA :-)
> 
> I know, that you dislike c.l.a! (:-))

This has nothing to do with disliking, it's a pure (and poor) fact that CLA is 
full of misinformation, wrong code examples (that e.g. do not compile) etc.



^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2002-04-24  5:27 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-22  8:34 type or subtype? Grein, Christoph
2002-04-22 11:49 ` Dmitry A. Kazakov
  -- strict thread matches above, loose matches on Subject: below --
2002-04-24  5:27 Grein, Christoph
2002-04-23  1:42 Alexandre E. Kopilovitch
2002-04-22 13:18 Grein, Christoph
2002-04-22 15:01 ` Dmitry A. Kazakov
2002-04-23  0:01   ` Robert Dewar
2002-04-22 13:09 Grein, Christoph
2002-04-22 13:58 ` Dmitry A. Kazakov
2002-04-22  8:14 Grein, Christoph
2002-04-22 11:36 ` Dmitry A. Kazakov
2002-04-17 12:44 Dmitry A. Kazakov
2002-04-17 12:50 ` Jean-Marc Bourguet
2002-04-17 13:55   ` Dmitry A. Kazakov
2002-04-17 14:10     ` Jean-Marc Bourguet
2002-04-18  4:50       ` Robert Dewar
2002-04-18  7:34       ` Dmitry A. Kazakov
2002-04-18  4:29 ` Richard Riehle
2002-04-18  7:51   ` Dmitry A. Kazakov
2002-04-18  4:48 ` Robert Dewar
2002-04-18  8:17   ` Dmitry A. Kazakov
2002-04-19 11:52     ` Robert Dewar
2002-04-22  7:33       ` Dmitry A. Kazakov
2002-04-19 11:54     ` Robert Dewar
2002-04-22  7:58       ` Dmitry A. Kazakov
2002-04-22 13:39         ` Robert Dewar
2002-04-22 14:41           ` Dmitry A. Kazakov

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