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,88093378be1184d4 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-09 15:28:40 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!sn-xit-01!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Matthew Heaney" Newsgroups: comp.lang.ada Subject: Re: A question and a request Date: Fri, 9 Nov 2001 18:32:03 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 X-Complaints-To: newsabuse@supernews.com Xref: archiver1.google.com comp.lang.ada:16180 Date: 2001-11-09T18:32:03-05:00 List-Id: "Eric Merritt" wrote in message news:mailman.1005116423.21054.comp.lang.ada@ada.eu.org... > The addition operator is taking two disparate but > related types and adding them. You have to be careful about how you use the terms "type" and "subtype". The (sub)types you defined simply name subsets of a common type. > This is fine, > up-casting is a normal thing. However, when the result > is returned it is not (should not be?) an instance of > the subtype. The addition operator looks like this: function "+" (L, R : Integer'Base) return Integer'Base; Only a "type" has operations. Subtypes merely name a range of values within the scalar type. Your addition operator is returning a value in the set (whose values are named by the type). Then there is an assignment, which checks to make sure the value (on the RHS) lies in the range of the subtype (of the object on the LHS). > It seems that the compiler is > down-casting automatically. This bothers me and it > seams that is violates Ada's strong typing. What am I > missing here? No, it does not, because there is only one type: the type whose first named subtype is Integer.