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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cc4f25d878383cc X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-09 14:58:28 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!fu-berlin.de!uni-berlin.de!ppp-2-126.cvx5.telinco.NET!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Re: Dimensionality Checking (Ada 20XX) Date: Sun, 9 Dec 2001 22:58:11 -0000 Message-ID: <9v0qai$bs584$1@ID-25716.news.dfncis.de> References: <11bf7180.0112070815.2625851b@posting.google.com> <9v0crt$bo2bi$1@ID-25716.news.dfncis.de> NNTP-Posting-Host: ppp-2-126.cvx5.telinco.net (212.1.153.126) X-Trace: fu-berlin.de 1007938707 12457220 212.1.153.126 (16 [25716]) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Xref: archiver1.google.com comp.lang.ada:17658 Date: 2001-12-09T22:58:11+00:00 List-Id: Some details. Fixed point types and objects would have the attribute Unit, of type Ada.Units.Unit_Type. A 'unit' (a value of this type) has two (notional or actual) components: its 'dimensionality', of type Ada.Units.Dimensionality, obtainable by the function Dim; and its 'scaling', of type universal_real, obtainable by the function Scaling. The types Ada.Units.Unit_Type and Ada.Units.Dimensionality would be 'static' subtypes: a constant of such a subtype whose initial value is static, is itself static. The Ada.Units package would include (in addition to what I said in my previous post): function "*" (Left: Unit_Type; Right: universal_integer) return Unit_Type; function "*" (Left: universal_integer; Right: Unit_Type) return Unit_Type; function "/" (Left: Unit_Type; Right: universal_integer) return Unit_Type; function "/" (Left: universal_integer; Right: Unit_Type) return Unit_Type; function "**" (Left: Unit_Type; Right: universal_integer) return Unit_Type; function Scaling (The_Unit: in Unit_Type) return universal_real; type Dimensionality is private; function Dim (The_Unit: in Unit_Type) return Dimensionality; For the (explicit) conversion between two unit-specific (fixed point) types, their dimensionalities must be the same. Conversion between a unit-specific and a non-unit-specific type entails no dimensionality check. The value of Scaling(T'Unit) for any non-unit-specific fixed point type T is always 1.0. For the value conversion: T1(X) where X is of type T2, where T1 and T2 are both fixed point, the value of the result would be the value of X*Scaling(T1'Unit)/Scaling(T2'Unit). For the view conversion (an actual parameter): T1(X) where X is of type T2, where T1 and T2 are both fixed point, the value passed in (to the subprogram being called) would be the value of X*Scaling(T1'Unit)/Scaling(T2'Unit), and the value passed out (back into X) would be the value of X*Scaling(T2'Unit)/Scaling(T1'Unit). There would be the following extra rules for the predefined multiplication and division operations. For multiplication: function "*"(Left: in universal_fixed; Right: in universal_fixed) return universal_fixed; the value of the result is the value of (Left*Scaling(Left'Unit))*(Right*Scaling(Right'Unit)), and, if the expected type is unit-specific, it must have the same dimensions as Dim(Left'Unit*Right'Unit). For division: function "/"(Left: in universal_fixed; Right: in universal_fixed) return universal_fixed; the value of the result is the value of (Left*Scaling(Left'Unit))/(Right*Scaling(Right'Unit)), and, if the expected type is unit-specific, it must have the same dimensions as Dim(Left'Unit/Right'Unit). For predefined exponentiation of any fixed point type T1, the function declaration becomes: function "**"(Left: in T1; Right: in Integer'Base) return T2; the value of the result is the value of (Left*Scaling(Left'Unit))**Right, and, if the type T1 is unit-specific, T2 is an anonymous fixed point type which is the same as T1 except that it has the dimensions of Left'Dimensionality**Right (otherwise T2 is identical to T1). In all other cases the semantics are as in Ada 95. -- Best wishes, Nick Roberts