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=-0.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3885b7fd66a1db28 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-11 10:13:50 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!news.gtei.net!newsfeed.mathworks.com!cyclone.swbell.net!bos-service1.ext.raytheon.com!bos-service2.ext.raytheon.com.POSTED!not-for-mail From: Wes Groleau Reply-To: wesgroleau@despammed.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: en,es-MX,es,pt,fr-CA,fr MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Why is Ada NOT a good choice for a beginner to programming? References: <8ivo1vo5ir3piqsck4ondj0cuo47g426kf@4ax.com> <9gMS9.483613$GR5.189928@rwcrnsc51.ops.asp.att.net> <3E200981.DC3A4A37@adaworks.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Sat, 11 Jan 2003 13:13:49 -0500 NNTP-Posting-Host: 151.168.133.155 X-Complaints-To: news@ext.ray.com X-Trace: bos-service2.ext.raytheon.com 1042308830 151.168.133.155 (Sat, 11 Jan 2003 13:13:50 EST) NNTP-Posting-Date: Sat, 11 Jan 2003 13:13:50 EST Organization: Raytheon Company Xref: archiver1.google.com comp.lang.ada:32919 Date: 2003-01-11T13:13:49-05:00 List-Id: Richard Riehle wrote: > We can still achieve compile-time safety using generic formal package > parameters. The following code does not directly address the derived > type issue, but it does illustrate a model that can be modified to > provide a solution to this problem. In some ways, it is like putting > a wrapper around the data type, as suggested in the C++ example > from Hyman Rosen. Except the multiplying operators package should have three formal types (and a conversion factor that defaults to 1.0) so that it can provide TA * TB = TC TC / TA = TB TB * TA = TC TC / TB = TA And we still haven't made length * length = length illegal. Can this be done as follows? Application: package Length_Types is new Dimensioned_Float (Significant_Digits => 12); type Length is new Length_Types.Dimension; package Area_Types is new Dimensioned_Float (Significant_Digits => 12); type Area is new Area_Types.Dimension; package Multipliers is new Multiplying_Operators (Term_One, Term_Two => Length, Product => Area); Library: generic ... Significant_Digits ... package Dimensioned_Float is type Dimensioned is digits Significant_Digits; -- "+" and "-" are now available just as we want them -- Now we must declare the default "*" and "/" illegal: function "*" (Left, Right : Dimensioned) return Dimensioned is abstract; function "/" (Left, Right : Dimensioned) return Dimensioned is abstract; .... Or will the compiler _insist_ that the abstraction be implemented?