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,edfa88b682578b7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-25 08:34:03 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mheaney@on2.com (Matthew Heaney) Newsgroups: comp.lang.ada Subject: Re: Overhead for type conversions? Date: 25 Jul 2003 08:34:02 -0700 Organization: http://groups.google.com/ Message-ID: <1ec946d1.0307250734.13c1a4d8@posting.google.com> References: NNTP-Posting-Host: 66.162.65.162 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1059147242 13458 127.0.0.1 (25 Jul 2003 15:34:02 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 25 Jul 2003 15:34:02 GMT Xref: archiver1.google.com comp.lang.ada:40808 Date: 2003-07-25T15:34:02+00:00 List-Id: "Bobby D. Bryant" wrote in message news:... > Given these declarations - > > type f1 is new float; > type f2 is new float; > > function "*"( left : in f1; right : in f2 ) return f1 is > begin > return( left * f1( right ) ); > end "*"; > > and given that run-time range checks are enabled, should I expect my > compiler to execute range checking code for each f1*f2 multiplication, > or will the compiler conclude from the definitions that the two types > are always convertible without error regardless of the specific value, > and thus not generate any code for a range check? Floating point types don't have constraint checks, unless the type is declared that way. The declaration type FT is digits 6; doesn't have any range constraint, and I think that means that there are no constraint checks. I'm not sure about overflow checks. However, the type declaration type FT is digits 6 range X .. Y; does have a constraint, and so constraint checks apply. This was one of the changes from Ada83 to Ada95: part of the ARG's charter was to improve efficiency. So to answer your question, I don't think there is any overhead for the type conversion. There are no constraint checks, because the type doesn't have any constraints. If the type had had constraints, then constraint checks would apply. Bob Duff answered a similar question about the floating point base types, on CLA during 1997/10/03: http://groups.google.com/groups?q=+%27base+group:comp.lang.ada+author:duff&hl=en&lr=&ie=UTF-8&selm=EHHp4E.AC4%40world.std.com&rnum=4 See also: http://groups.google.com/groups?q=+%27base+group:comp.lang.ada+author:duff&hl=en&lr=&ie=UTF-8&selm=E4oE3q.1tq%40world.std.com&rnum=1 -Matt