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=-2.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=unavailable 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-06 23:00:24 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!fr.usenet-edu.net!usenet-edu.net!enst!enst.fr!not-for-mail From: Eric Merritt Newsgroups: comp.lang.ada Subject: A question and a request Date: Tue, 6 Nov 2001 20:44:19 -0800 (PST) Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: avanie.enst.fr 1005116423 29052 137.194.161.2 (7 Nov 2001 07:00:23 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Wed, 7 Nov 2001 07:00:23 +0000 (UTC) To: comp.lang.ada@ada.eu.org Return-Path: In-Reply-To: <9s9t16$11ia3i$1@ID-25716.news.dfncis.de> Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.6 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:15972 Date: 2001-11-06T20:44:19-08:00 As some of you may know I am fairly new to Ada and I just found out something that surprised me. I declared two subtypes of an integer. I was then able to add these two types together and assign the result to an instance of one of the above subtypes. or subtype type_1 is Integer; subtype type_2 is Integer; type_1_instance : type_1; type_2_instance : type_2; type_1_instance_2 : type_1; type_1_instance := 1; type_2_instance := 2; type_1_instance_2 := type_1_instance + type_2_instance; The addition operator is taking two disparate but related types and adding them. 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. 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? My request is a bit simpler, is there any one out there willing to serve as kind of a quasi-mentor. Basically look at some simple code occasionally and tell me when I am getting bad habits. I have found when learning other languages without experienced input that I am able to pick up the language in a few weeks or months and then it takes me a couple of years to realize I have bad habits and attempt to rectify them. This shouldn't be too time consuming for the volunteer. I have been programming in other languages professionally (C/C++, Java, Perl and Python) and I have a good understanding of the theory. I just need someone to occasionally look and say "hey this is stupid, in Ada do it this way" or "In Ada its better to take this approach". I could post stuff to the list but this seams to be poor etiquette. In any case, if I get an answer to my first question I will be happy. Thanks __________________________________________________ Do You Yahoo!? Find a job, post your resume. http://careers.yahoo.com