TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Reply To:
Niklas Holsti <[log in to unmask]>
Sun, 3 Feb 2002 10:22:18 +0200
text/plain (24 lines)
On Sat, Feb 02, 2002 at 09:55:14AM -0500, [log in to unmask] wrote:
> I must admit that I have not done this often (though I have done it), but I
> see more than "limited" value in creating a type, defining operations for
> it, and then deriving independent types that inherit the same operations.

In a software tool we are developing (for static worst-case execution-time
analysis) I count some 60 derivations of new untagged types, many from
predefined types like Natural or Positive. The reason for using
derived types in most cases is to enforce strong type checks for indices
and counters where we have no a priori reason to set a specific range
(as in "type T is range 1 .. 100"). Another reason is to override the
predefined stream I/O attributes (Read, Write etc.) with procedures
that apply specific lay-outs, byte ordering, or checks such as accumulating
a check-sum of the bytes read or written.

In other applications, I have used type derivation of record types to
enjoy the automatic lay-out conversion that occurs on conversion between
related record types with different record representation clauses.

So I have found derived types useful even in the non-tagged case.

Niklas Holsti
Working at but not speaking for Space Systems Finland Ltd.