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: 103376,703c4f68db81387d X-Google-Thread: 109fba,703c4f68db81387d X-Google-Thread: 115aec,703c4f68db81387d X-Google-Thread: f43e6,703c4f68db81387d X-Google-Attributes: gid103376,gid109fba,gid115aec,gidf43e6,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!proxad.net!proxad.net!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: [OT] Re: Teaching new tricks to an old dog (C++ -->Ada) Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng User-Agent: 40tude_Dialog/2.0.14.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: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <1110032222.447846.167060@g14g2000cwa.googlegroups.com> <871xau9nlh.fsf@insalien.org> <3SjWd.103128$Vf.3969241@news000.worldonline.dk> <87r7iu85lf.fsf@insalien.org> <87is4598pm.fsf@insalien.org> Date: Sun, 6 Mar 2005 08:54:12 +0100 Message-ID: <5fh910ca5yiu.1b2z0d2u2hguu.dlg@40tude.net> NNTP-Posting-Date: 06 Mar 2005 08:54:00 MET NNTP-Posting-Host: 219f9b09.newsread4.arcor-online.net X-Trace: DXC=KZf^2LW=ni7GKQ1;SL\gZ1:ejgIfPPld4jW\KbG]kaM8GSi?jHD8GO0bjgW5j\LYK7[6LHn;2LCV>COgUkn_?_Y?D\WW9GEV\G6 X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:8725 comp.lang.c++:44299 comp.realtime:1001 comp.software-eng:4532 Date: 2005-03-06T08:54:00+01:00 List-Id: On Sat, 5 Mar 2005 23:44:56 +0100, Peter Koch Larsen wrote: > "Ludovic Brenta" skrev i en meddelelse > news:87is4598pm.fsf@insalien.org... >> This is the crux of the problem. Assuming that the programmer "knows >> the rules", "makes no mistakes" or "can be trusted" is a recipe for >> disaster. One of the principles in Ada's rationale is to make >> everything explicit, rather than implicit. > > Do you also require parenthesis when mixing addition and multiplication? I > do not like that degree of nannying - a matter of taste, surely. That's the Ada's way. The following is also illegal without brackets: + - 2 A**+2 Though they might look unambiguous, no sensible man would write something like above. As for addition and multiplication. The association rules of */+ differs from ones of and/or: x + (y * z) is not equivalent to (x + y) * (x + z) So there is a canonic representation of algebraic expressions with */+. For and/or the picture is different: x and (y or z) = (x and y) or (x and z) (x and y) or z = (x or z) and (y or z) There is no dedicated representation: a normal disjunctive form is as good as a normal conjunctive one. >> type Weight is digits 8 range 0.0 .. 900.0; -- 8 decimal digits of >> precision >> type Length is digits 8 range 0.0 .. 1000.0; >> >> Now these types are incompatible. If you want to mix them, you need >> to define the semantics and provide the appropriate operators: >> >> type Weight_Length is digits 8 range 0.0 .. 900_000.0; >> >> function "*" (Left : in Weight; Right : in Length) return Weight_Length; >> >> Since you don't provide "+", there is no way to add a weight to a >> length. >> >> For a more general discussion of physical quantities in Ada, see: >> >> http://home.t-online.de/home/Christ-Usch.Grein/Ada/Universe.html > > I believe I will prefer the C++ solution - a template that copes with all > this stuff. Try to write a unit calculator using templates ... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de