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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.42.60.133 with SMTP id q5mr14813898ich.10.1411750739507; Fri, 26 Sep 2014 09:58:59 -0700 (PDT) X-Received: by 10.140.19.2 with SMTP id 2mr8475qgg.35.1411750739365; Fri, 26 Sep 2014 09:58:59 -0700 (PDT) Path: buffer2.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!a13no4053905igq.0!news-out.google.com!i10ni38qaf.0!nntp.google.com!k15no48576qaq.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 26 Sep 2014 09:58:59 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=91.55.226.199; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf NNTP-Posting-Host: 91.55.226.199 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <98f0066e-4b5c-4b00-b811-dcbb13ed0fcf@googlegroups.com> Subject: Re: Integers and Mathematical Correctness From: AdaMagica Injection-Date: Fri, 26 Sep 2014 16:58:59 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: number.nntp.dca.giganews.com comp.lang.ada:189180 Date: 2014-09-26T09:58:59-07:00 List-Id: On Friday, September 26, 2014 6:38:10 PM UTC+2, Niklas Holsti wrote: > False. Ada can overload operators on the result type, so you can very > well add > > function "/" (Left, Right : Integer) return Rational; > > and have both"/" visible and used with in-fix notation. Nah, it's not that easy. The reason is that Integer is defined in Standard, which always has precedence for any use-clause. You need a separate integer type type Whole is range ... function "/" (Left, Right: Whole) return Rational; There is a complete implementation in http://www.christ-usch-grein.homepage.t-online.de/Ada/Dimension/SI.html with Text_IO, Image and Value; appropriate test units exist also. GNAT had much fun with overload resolution - it took very long until it could deal with my rational numbers.