Sun, 3 Feb 2002 10:22:18 +0200
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.
Working at but not speaking for Space Systems Finland Ltd.