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 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a24:294d:: with SMTP id p74-v6mr1189838itp.36.1533822466472; Thu, 09 Aug 2018 06:47:46 -0700 (PDT) X-Received: by 2002:aca:c6ca:: with SMTP id w193-v6mr85433oif.1.1533822466277; Thu, 09 Aug 2018 06:47:46 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!feeder4.usenet.farm!feed.usenet.farm!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!g24-v6no2976122iti.0!news-out.google.com!k71-v6ni3710itk.0!nntp.google.com!g24-v6no2976120iti.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 9 Aug 2018 06:47:46 -0700 (PDT) In-Reply-To: <9381f30a-a957-4477-b037-b2d60041e83e@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=47.185.195.62; posting-account=zwxLlwoAAAChLBU7oraRzNDnqQYkYbpo NNTP-Posting-Host: 47.185.195.62 References: <9381f30a-a957-4477-b037-b2d60041e83e@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: SI Units Checked and Unchecked From: "Dan'l Miller" Injection-Date: Thu, 09 Aug 2018 13:47:46 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:54105 Date: 2018-08-09T06:47:46-07:00 List-Id: On Thursday, August 9, 2018 at 7:44:13 AM UTC-5, AdaMagica wrote: > This is a complete rework using Ada 2012 predicates. >=20 > These packages provide a method to commpute with physical items in full g= enerality under dimensional correctness checking. Dimensioned items are wri= tten in a natural style with the unit attached as a string. >=20 > The base type is private: >=20 > type Item is private; >=20 > There are subtypes defined for all 7 base units defined in the SI system = and many more: >=20 > subtype Length is Item with Dynamic_Predicate =3D> has_Dimension (Lengt= h, "m"); > subtype Volume is Item with Dynamic_Predicate =3D> has_Dimension (Volum= e, "m**3"); > subtype Speed is Item with Dynamic_Predicate =3D> has_Dimension (Speed= , "m/s"); > subtype Force is Item with Dynamic_Predicate =3D> has_Dimension (Force= , "N"); > subtype Resistance is Item with Dynamic_Predicate =3D> has_Dimension (R= esistance, "Ohm"); >=20 > Variables are defined like this: >=20 > A: Acceleration :=3D 5.0*"m/s**2"; > V: Speed :=3D 10.0*"km/h"; > T: Time :=3D 1.0*"min"; > D: Length :=3D V*T + 0.5*A*T**2; >=20 > D :=3D 1.0*"J"; will raise an exception. Shouldn't the =E2=80=A2entire=E2=80=A2 point of a units-of-measurement libr= ary (or feature of language) be compile-time errors, not run-time exception= s/errors. > Units and prefixes are case sensitive (as defined in SI): "mS" is millisi= emens, "Ms" is megasecond. >=20 > Dimensioned IO is also provided: >=20 > V :=3D 1.0*"m/s"; -- output as > Put (V); -- 1.0*m*s**(-1) > Put (V, Dim =3D> "km/h"); -- 3.6*km/h > Put (V, Dim =3D> "s"); -- will raise an exception >=20 > Download from here: > http://www.christ-usch-grein.homepage.t-online.de/Ada/Dimension/SI.html >=20 > If you should use (even like) this method, please drop me a note with you= r findings. I am an advocate of units-of-measure in programming. I would be interested in a summary (or even better, an AI) that itemizes al= l the core-language obstacles in currently-standardized Ada to moving all t= he incompatible usages of units to be compile-time errors instead of raisin= g exceptions.