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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9cccf6ef6149fdaa X-Google-Attributes: gid103376,public From: "Matthew Heaney" Subject: Re: Operators -> unit analysis Date: 2000/01/05 Message-ID: <3873a69a_1@news1.prserv.net>#1/1 X-Deja-AN: 568780215 Content-transfer-encoding: 7bit References: <38620350.48F8FC08@gecm.com> <83u8l0$5i5$1@nnrp1.deja.com> <84rd2f$snm$1@nntp3.atl.mindspring.net> <84thof$9r3$1@nntp4.atl.mindspring.net> <387383D0.4EA02E95@earthlink.net> Content-Type: text/plain; charset="US-ASCII" X-Complaints-To: abuse@prserv.net X-Trace: 5 Jan 2000 20:16:26 GMT, 129.37.62.74 Organization: Global Network Services - Remote Access Mail & News Services Mime-version: 1.0 Newsgroups: comp.lang.ada Date: 2000-01-05T00:00:00+00:00 List-Id: In article <387383D0.4EA02E95@earthlink.net> , Charles Hixson wrote: > And some good way to handle units. So that we could safely say things like: > > speed := 37.miles / 1.5.hours; > I'm not too pleased with the syntax, but the idea is there. You can already do this: Speed := Miles'(37.0) / Hours'(1.5); I always recommend type qualification for literals when units are an issue. > I dislike the syntax: > speed := (37 * mile) / (1.5 * hour); > though I prefer it to: > speed := miles (37) / hours (1.5); > but that's the best that I know how to do it in Ada. Is there a better > choice? (I.e. one that would look more like what a math student would write > in a word problem?) See above. > Of course one could say: > dist : constant Miles := 37; > time : constant Hours := 1.5; > speed : MpH; > speed := dist / time; > > but that seems quite unnecessarily verbose! Agreed.