Print

Print


Stephen Leake <[log in to unmask]> wrote:
>So I stand by my statement; deriving new types from user-defined
>non-tagged types is rarely useful.

Your statement wasn't exactly that. Here is what you wrote Mon, 28 Jan 2002 13:03:42,
(Message-ID:  <[log in to unmask]>) :

>Integer, Float, etc are un-tagged, so we can derive from them, but not
>extend them. This form of derivation is of limited use.

There was nothing about the derivation from the *user-defined* non-tagged types,
since Integer and Float are standard types, and therefore they hardly can be
considered as user-defined types.

  Now to the essense:

>This is a "subtype", not a "derived type". A "derived type" uses the
>word "new", as in:
>
>type Derived_Task_Id_Type is new Task_Id_Type;
>
>Same here; all subtypes, not derived types.
>
>So I stand by my statement; deriving new types from user-defined
>non-tagged types is rarely useful.

From the pedantic viepoint, the claim that the derived types and the subtypes
are completely different things may be true. Yes, the word "new" is needed for
the derivation from the type, in strict sense of the term "derived type",
Therefore it would be ok to say:

   Integer, Float, etc are un-tagged, so we can derive from them, but not
   extend them. This form of derivation is of limited use. There are other
   entities in Ada, called "subtypes", which provide a form of differentiation
   within a type.

You might explain what subtypes are, or not, but it occured that you kept silent
about them at all, and at the same time provided the "pragma" about limited use
of the derivation from the un-tagged types. With that you, intentionally or not,
claimed that the power of the type system in Ada95 is roughly and/or practically
the same as in C++, etc.

In fact, the subtypes have much in common with the derived types, and it isn't
a coincidence that the derivation (from the non-tagged types) and subtyping
are considered either in neighbouring sections or even together (as in well-known
books "Programming in Ada95" by Barnes, and "Ada as Second Language" by Cohen).
Practically, the subtypes differ from the distinct type in that a compiler
generally permits mixing the different subtypes of the same type in an assignment,
but 1) the run-time checks are provided by the same compiler, and 2) the subtype
information is available for both a programmer and the custom verification tools,
which may perform additional checks. The latter means, in particular, that one
may relatively easily create the custom extentions of the type system, that are
based on subtypes.


Alexander Kopilovitch                      [log in to unmask]
Saint-Petersburg
Russia