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,fcdd0f6139250dc5 X-Google-Attributes: gid103376,public From: Jeff Carter Subject: Re: Tagged Types and Generics Date: 1997/04/24 Message-ID: <335F67FF.41C67EA6@spam.innocon.com>#1/1 X-Deja-AN: 237048774 References: <3.0.32.19970421225247.007129f4@mail.4dcomm.com> Organization: Innovative Concepts, Inc. Newsgroups: comp.lang.ada Date: 1997-04-24T00:00:00+00:00 List-Id: Robert C. Leif, Ph.D. wrote: >... > generic > > type Num_Or_Denom is delta <> digits <>; > type Ratio is delta <> digits <>; > > package Dec_Divide is > > type Num_Or_Denoms is abstract tagged private; > --This the start of the class > > Function Ratio_Test(Numerator : in Num_Or_Denoms'Class; > Denominator : in Num_Or_Denoms'Class) > return Ratio; > Private > type Num_Or_Denoms is abstract tagged > record > The_Num_Or_Denom : Num_Or_Denom; > Num_Or_Denom_Scale: Integer := Num_Or_Denom'Scale; > Num_Or_Denom_digits: Integer := Num_Or_Denom'digits ; > end record; > end Dec_Divide; I don't see any point to this. All objects in Num_Or_Denoms'Class have the same type for component The_Num_Or_Denom, and the same default values for components Num_Or_Denom_Scale and Num_Or_Denom_Digits. > 46. Procedure Divide is new Ada.Decimal.Divide > 47. (Dividend_type => Gen_Numerator, > 48. Divisor_Type => Gen_Denominator, > 49. Quotient_Type => Ratio, > 50. Remainder_Type => Ratio); > 51. > 52. Use Divide; > | > >>> "Divide" is not a usable package This instantiation creates a procedure. You can't "use" a procedure. If you could do it, this would be the same as procedure Divide is new Ada.Decimal.Divide (Dividend_Type => Num_Or_Denom, Divisor_Type => Num_Or_Denom, Quotient_Type => Ratio, Remainder_Type => Ratio); unless you somehow changed the values of the components Num_Or_Denom_Scale and Num_Or_Denom_Digits. Perhaps you had planned on a way to do this, but it's not clear from your post. Even if you change these values, the numbers you are dividing are still of type Num_Or_Denom, and your result of type Ratio. You are simply performing a conversion to another type, equivalent to: type Z is delta A digits B; type Y is delta C digits D; type X is delta E digits F; type W is delta G digits H; procedure Divide is new Ada.Decimal.Divide (Dividend_Type => Y, Divisor_Type => X, Quotient_Type => W, Remainder_Type => W); Dend : Z; Sor : Z; Quot : W; Rmdr : W; ... Divide (Dividend => Y (Dend), Divisor => X (Sor), Quotient => Quot, Remainder => Rmdr); Watch out for the auntie-spam return address. -- Jeff Carter ( carter @ innocon . com ) PGP:1024/440FBE21 "Now go away, or I shall taunt you a second time." Monty Python & the Holy Grail