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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1901f265c928a511 X-Google-Attributes: gid103376,public Path: controlnews3.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Tue, 01 Jun 2004 23:39:10 -0500 Date: Wed, 02 Jun 2004 00:39:10 -0400 From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Typing in Ada References: <2i1t1lFij4g5U1@uni-berlin.de> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.147.90.114 X-Trace: sv3-pSs6qilkFS2BAwWlTXuGmLvnOgFl5aBY8zqG1rjaZCRHjV/Bl6YzLE5m7hDdKHQvBb+Iknhgsaor9FU!2FI+49FzsDCNz24auu4t24vXCnwd3nzB2zK6G/OfJ/Yv6zX6JmfPx/Fkfl+Wug== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: controlnews3.google.com comp.lang.ada:1008 Date: 2004-06-02T00:39:10-04:00 List-Id: Peter C. Chapin wrote: > Yes, Ada provides ranges as distinct types without automatic conversions > and that's a nice feature. In theory you could get some of the same > benifits in C by introducing an abstract type (as a structure) to hold a > range. It could be done much more nicely in C++ using templates, > overloaded operators, and other C++ features. The reality is, though, that > many C (or C++) programs don't bother. Perhaps they should. > > It's not clear to me how all this relates to the concept of strong typing. > I guess it would be helpful to have a precise definition of that term. It > sounds like from what we've said here that strong typing more a matter of > programming style than a language feature... at least where C and Ada are > concerned. Is that a valid conclusion? I guess the real difference between C (or C++) and Ada is that Ada has many features you get "for free" at compile time if you use strong typing. The most visible of these in Ada is overloading and overload resolution. To extend the Apples and Oranges example, if I define type Apple is (McIntosh, Granny_Smith, Winesap, Golden_Delicious,...); type Orange is (Valencia, Navel, Mandarin, Seville, Bergamot...); then Eat(McIntosh); -- will call the Eat function for Apples, and Eat(Navel); -- will call the Eat function for Oranges, and peel it first. ;-) The most important benefit of this is that if a procedure or functions has a multitude of parameters some possibly with defaults, when programming in Ada, you don't have to "validate" the call against the function template. The compiler will do that for you, and detect most errors. Of course, if you write "C := A - B;" when you meant "C := B - A;" the compiler probably won't catch that. However there are cases where it will. For example, Ada.Calendar defines: function "-" (Left : Time; Right : Duration) return Time; function "-" (Left : Time; Right : Time) return Duration; But no operation for subtracting Time from Duration. So Ada would catch a call to the first "-" with the parameters in the wrong order, but could not detect such an inversion if the parameters were both of type Time. -- Robert I. Eachus "The terrorists rejoice in the killing of the innocent, and have promised similar violence against Americans, against all free peoples, and against any Muslims who reject their ideology of murder. Their barbarism cannot be appeased, and their hatred cannot be satisfied. There's only one way to deal with terror: We must confront the enemy and stay on the offensive until these killers are defeated." -- George W. Bush