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-Thread: 103376,fc52c633190162e0 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!y66g2000hsf.googlegroups.com!not-for-mail From: "jimmaureenrogers@worldnet.att.net" Newsgroups: comp.lang.ada Subject: Re: why learn C? Date: 2 Apr 2007 19:58:55 -0700 Organization: http://groups.google.com Message-ID: <1175569135.870153.100890@y66g2000hsf.googlegroups.com> References: <1172144043.746296.44680@m58g2000cwm.googlegroups.com> <1172161751.573558.24140@h3g2000cwc.googlegroups.com> <546qkhF1tr7dtU1@mid.individual.net> <5ZULh.48$YL5.40@newssvr29.news.prodigy.net> <1175215906.645110.217810@e65g2000hsc.googlegroups.com> <1175230352.808212.15550@e65g2000hsc.googlegroups.com> <1175236212.771445.135460@y66g2000hsf.googlegroups.com> <1175308871.266257.77460@e65g2000hsc.googlegroups.com> <1175501602.127760.186120@q75g2000hsh.googlegroups.com> NNTP-Posting-Host: 75.70.221.169 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1175569137 26237 127.0.0.1 (3 Apr 2007 02:58:57 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 3 Apr 2007 02:58:57 +0000 (UTC) In-Reply-To: <1175501602.127760.186120@q75g2000hsh.googlegroups.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.11) Gecko/20070312 Firefox/1.5.0.11,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: y66g2000hsf.googlegroups.com; posting-host=75.70.221.169; posting-account=SqOfxAwAAAAkL81YAPGH1JdBwpUXw9ZG Xref: g2news1.google.com comp.lang.ada:14756 Date: 2007-04-02T19:58:55-07:00 List-Id: On Apr 2, 2:13 am, "kevin cline" wrote: > On Mar 30, 9:41 pm, "jimmaureenrog...@worldnet.att.net" For instance: > > No, run time checks are needed for things that cannot be checked at > > compile time. Ada helps is more helpful with run time checks than is > > C or C++ due to the automated check writing built by the compilers. > > For instance, if you define an integer type with a valid range of > > values from -10 to 10, the compiler will perform all necessary > > range checking for that type. > > > type My_Int is range -10..10; > > That's perfect if it happens to be the exact thing that you need. It > doesn't help much if what you need is a point inside the unit circle. > That is an interesting non-sequiter. No integer type would be satisfactory to define a point within a unit circle. > In C++ the language provides neither of these things, but they are > both be implemented in a few lines of code. > > In Ada, the implementation of the constrained point is not so > obvious. You want a type for specification of a point within a unit circle. Is this really hard to comprehend: type Unit_Radius_Type is digits 15 range 0.0..1.0; type Angle is digits 15 range 0.0..2.0 * Pi; type Circular_Point is record X : Unit_Radius_Type; Theta : Angle; end record; Given any unit circle with a known center coordinate, all points can be designated within 15 digits of accuracy. Please demonstrate how you would use C++ templates to create an equivalent definition. I am most curious about the range-specified and precision-specified floating point types. Jim Rogers