comp.lang.ada
 help / color / mirror / Atom feed
From: Richard D Riehle <laoXhai@ix.netcom.com>
Subject: Re: Engineering types hierarchy
Date: 1999/09/11
Date: 1999-09-11T15:43:51-05:00	[thread overview]
Message-ID: <7reeu7$t89@dfw-ixnews6.ix.netcom.com> (raw)
In-Reply-To: 7r75hc$sdi4@svlss.lmms.lmco.com

In article <7r75hc$sdi4@svlss.lmms.lmco.com>,
	dkristol@see-my.sig (David Kristola) wrote:

>I took a look at the above site and did not see anything
>that seemed useful.  There are plenty of ADTs there, but
>i did not even see anything along the lines of Pat Rogers'
>"dimensioned units"
>(http://www.classwide.com/products/freecode.htm).

I don't know if it will be helpful to you, but one of our clients
has found it useful to take advantage of Ada's generic formal
package parameter model, starting with a signature package.

generic
  type Item is digits <>;
  with function "+" (L, R : Item) return Item is <>;
  -- repeat for each arithmetic operator
  with function "=" (L, R : Item) return Item is <>;
  -- repeat for each logical operator
package Float_Math_Signature is end Float_Math_Signature;

This can now be instantiated in lots of places where you need to do 
math operations on your own type.  For example, you might write
your own version of "=" or "/" for a particular floating point type.
I have a version of this that even works for private types.

This can be used in conjunction with "use type" too.

with Float_Math_Signature;
generic
   with package Math_Ops is new Float_Math_Signature(<>);
package Some_Computation_Package is 
    ...
end Some_Computation_Package;

This idea can be extended to further generalize your design so the
types can be decoupled from each other more effectively.  You can
use it with discriminants, but it may sometimes eliminate the need
for discriminants in some components.

Richard Riehle
http://www.adaworks.com




  reply	other threads:[~1999-09-11  0:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-08  0:00 Engineering types hierarchy David Kristola
1999-09-08  0:00 ` Robert Dewar
1999-09-09  0:00   ` David Kristola
1999-09-09  0:00     ` Robert Dewar
1999-09-10  0:00       ` David Kristola
1999-09-09  0:00     ` Robert Dewar
1999-09-08  0:00 ` Pat Rogers
1999-09-09  0:00   ` David Kristola
1999-09-08  0:00 ` Hyman Rosen
1999-09-08  0:00   ` Matthew Heaney
1999-09-08  0:00 ` Marin David Condic
1999-09-09  0:00   ` David Kristola
1999-09-11  0:00     ` Richard D Riehle [this message]
1999-09-08  0:00 ` Matthew Heaney
1999-09-09  0:00   ` David Kristola
1999-09-09  0:00 ` David Botton
1999-09-10  0:00   ` David Kristola
1999-09-10  0:00     ` Ted Dennison
  -- strict thread matches above, loose matches on Subject: below --
1999-09-09  0:00 Matthew Heaney
1999-09-09  0:00 ` Matthew Heaney
1999-09-09  0:00   ` Pat Rogers
1999-09-10  0:00   ` David Kristola
replies disabled

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