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 2002:a24:b045:: with SMTP id b5-v6mr1056776itj.35.1533818652818; Thu, 09 Aug 2018 05:44:12 -0700 (PDT) X-Received: by 2002:aca:c744:: with SMTP id x65-v6mr77986oif.2.1533818652620; Thu, 09 Aug 2018 05:44:12 -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!g13-v6no2829016itf.0!news-out.google.com!k71-v6ni3671itk.0!nntp.google.com!g13-v6no2829012itf.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 9 Aug 2018 05:44:12 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=84.131.53.122; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf NNTP-Posting-Host: 84.131.53.122 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <9381f30a-a957-4477-b037-b2d60041e83e@googlegroups.com> Subject: SI Units Checked and Unchecked From: AdaMagica Injection-Date: Thu, 09 Aug 2018 12:44:12 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:54102 Date: 2018-08-09T05:44:12-07:00 List-Id: This is a complete rework using Ada 2012 predicates. These packages provide a method to commpute with physical items in full generality under dimensional correctness checking. Dimensioned items are written in a natural style with the unit attached as a string. The base type is private: type Item is private; There are subtypes defined for all 7 base units defined in the SI system and many more: subtype Length is Item with Dynamic_Predicate => has_Dimension (Length, "m"); subtype Volume is Item with Dynamic_Predicate => has_Dimension (Volume, "m**3"); subtype Speed is Item with Dynamic_Predicate => has_Dimension (Speed , "m/s"); subtype Force is Item with Dynamic_Predicate => has_Dimension (Force , "N"); subtype Resistance is Item with Dynamic_Predicate => has_Dimension (Resistance, "Ohm"); Variables are defined like this: A: Acceleration := 5.0*"m/s**2"; V: Speed := 10.0*"km/h"; T: Time := 1.0*"min"; D: Length := V*T + 0.5*A*T**2; D := 1.0*"J"; will raise an exception. Units and prefixes are case sensitive (as defined in SI): "mS" is millisiemens, "Ms" is megasecond. Dimensioned IO is also provided: V := 1.0*"m/s"; -- output as Put (V); -- 1.0*m*s**(-1) Put (V, Dim => "km/h"); -- 3.6*km/h Put (V, Dim => "s"); -- will raise an exception Download from here: http://www.christ-usch-grein.homepage.t-online.de/Ada/Dimension/SI.html If you should use (even like) this method, please drop me a note with your findings. Have fun. Christoph