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 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: SI Units Checked and Unchecked Date: Sat, 11 Aug 2018 23:01:50 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <9381f30a-a957-4477-b037-b2d60041e83e@googlegroups.com> <60ddd5ae-57e1-45e8-929c-302fabaa24ef@googlegroups.com> <96424a63-d811-4ade-88db-258f3febe60a@googlegroups.com> <99af08dd-39fb-4c1e-a247-eef9680a2abd@googlegroups.com> <87k1oxfr9v.fsf@nightsong.com> <877ekw1xsi.fsf@nightsong.com> NNTP-Posting-Host: IzvqdhUtDGKIMCldyDtZ+w.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.8.3 Xref: reader02.eternal-september.org comp.lang.ada:54145 Date: 2018-08-11T23:01:50+02:00 List-Id: On 2018-08-11 21:57, Paul Rubin wrote: > "Dmitry A. Kazakov" writes: >>>> No language change can make dynamic cases static. >>> I think the idea is to allow constraints on generic instantiation >>> precise enough to use them for unit checking. >> Dynamic is not static. > > Well the idea is to check the constraints statically. The constraints are not static. > Obviously in > cases where values can be introduced at runtime, there must be a way to > connect them up with units, through protected methods or whatever. > Once they are in the system, the types track them. Tracking is a run-time action. If you know units statically you don't need to track them. In most cases as a value propagates the system it crosses barriers when one or another side does not know the unit. Reading a measurement value is only the first such barrier. > I don't understand why there is even a desire in a scientific-style > program to track quantities in more than one dimensionally equivalent > unit (e.g. liters vs gallons). Because it is a requirement. When designing an automation and control system, you have an HMI, which must show gallons because the operator wants to see gallons. The fuel flow measurement system may use liters per hour. The network protocol to transport measurement data will use a SI unit etc. No installation I ever saw used strictly SI units. Even in Europe temperature is reported in Celsius degree, speed is in km/s, inclination is in crazy percents of tangent. Who ever used ks instead of hour? > Just convert everything to a uniform set > of units (probably SI) when they come into the system, and then do all > internal calculations with that unit set. What calculations you mean? The calculations used in the controlling loop is well under 5% of all code and this is the only part that could have statically known units. Even that is not fully true because things like restbus simulation, computable user-defined channels do not have statically known units. Any other calculations used in logging, databases, interfacing the ERP, reporting, health monitoring, plausibility checking and hell knows other components deal with dynamic units. And all the non-calculating rest is dynamic too. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de