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: Fri, 10 Aug 2018 08:45:43 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <9381f30a-a957-4477-b037-b2d60041e83e@googlegroups.com> <60ddd5ae-57e1-45e8-929c-302fabaa24ef@googlegroups.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 X-Notice: Filtered by postfilter v. 0.8.3 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:54121 Date: 2018-08-10T08:45:43+02:00 List-Id: On 2018-08-10 00:12, Dan'l Miller wrote: > Actually, I am talking about compile-time checks within Ada source code for a gauge as would be utilized on the GUI control screen of a chemical plant or a nuclear reactor, not some toy string-processing app that is the analogue of GNU Units. As I explained this design is technically not viable. Even taking an insanely huge overhead of making all components generic with measurement unit as a formal parameter, that would be less safe than a design based on constraints. With generics you can only pass same actual parameter or use a generic instance as a parameter, you cannot constraint generic instances in a way the algebra of measurement units works, e.g. length divided to time gives speed. So you will end up with generic instances for each particular unit but no mechanism to combine instances (of different generic types) in a unit-safe way. It will be in effect *untyped*. (Which is does not really matter since internal mechanisms like queuing of events, callbacks etc cannot be made generic anyway.) Compile-time unit checks can only be used in some numeric problems, for instance in the control loop. Everywhere else checks are run-time, which in case of widgets does not mean any real safety loss because practically all these checks are done upon initialization. When you create a gauge you connect a signal from a slider widget to it. Doing so the units of the gauge and of the slider's signal get checked. That happens once before the system starts. If you use a GUI design tool then this check could be performed even earlier before deployment. Chances of getting a run-time check fail are zero. >> The scalars are not unitless. The unit is a discriminant: >> >> http://www.dmitry-kazakov.de/ada/units.htm > > It looks like a string-processing library to support a toy units converter app, No string processing involved. It is same as saying that Integer is string processing because there exists Integer'Image. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de