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, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,4b26cf620424a3ff X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!195.71.90.67.MISMATCH!news.unit0.net!noris.net!news.teledata-fn.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Language Revision : "/" and "div" Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <8aa58be8-a9b2-4653-8234-e5b6a70f310f@k41g2000yqb.googlegroups.com> Date: Sat, 1 May 2010 11:25:36 +0200 Message-ID: <1wcpicfucvich$.1ec1rjytiuj5s$.dlg@40tude.net> NNTP-Posting-Date: 01 May 2010 11:25:36 CEST NNTP-Posting-Host: 8d9313e6.newsspool4.arcor-online.net X-Trace: DXC=@;`L2>M3?>5U`5g[@c]@J14IUK67Cdc?24[6LHn;2LCV>[ On Fri, 30 Apr 2010 23:52:18 -0700 (PDT), vincent.diemunsch@gmail.com wrote: > I wonder why Ada uses "/" to express the integer division and not > "div". Because in most languages / denotes "integer division", which mathematical integer lack (:-)). > This leads to the fact that an expression like 4/3*6 that any decent calculator > would evaluate as 8 is in Ada evaluated as 6 !!! That is a shame :-). 1. The calculator uses reals, not integers. 2. There exist expression which cannot be evaluated (as decimal fractions of finite length), e.g. 1.0/3.0 3. There exist operations not closed in R. So a "decent" calculator should return j for sqrt(-1.0) 4. There exist operations not closed in C, e.g. multi-valued functions. A "decent" calculator must return a set of values? > - discard the function "/" (left, right : Integer) return Integer and > replace it by the operator "div", AFAIK, ARG does not introduce backward incompatibilities unless absolutely necessary (in their opinion (:-)). I doubt that / could fall under this category. > that sounds quite logical with the existing "rem" and "mod". > - add a fraction package with a function "/" (left, right : > Integer'base) return Fraction; as constructor. Arguably better would be "div" as a full division, e.g. returning a tuple of the result and the remainder. In both cases there is a problem that the result type (be it fraction, tuple, rational etc) shall be defined (inferred) for each integer type including user-defined ones. Ada lacks any mechanics for this. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de