From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1f0e8beefacb537e X-Google-Attributes: gid103376,public From: Richard D Riehle Subject: Re: Engineering types hierarchy Date: 1999/09/11 Message-ID: <7reeu7$t89@dfw-ixnews6.ix.netcom.com>#1/1 X-Deja-AN: 523878063 References: <37D6A316.5E2E5F73@pwfl.com> <7r75hc$sdi4@svlss.lmms.lmco.com> Organization: Netcom X-NETCOM-Date: Sat Sep 11 3:43:51 PM CDT 1999 X-Inktomi-Trace: sji-ca-cache 937082615 18282 209.109.233.39 (11 Sep 1999 20:43:35 GMT) Newsgroups: comp.lang.ada Date: 1999-09-11T15:43:51-05:00 List-Id: 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