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:a6b:1cc9:: with SMTP id c192-v6mr2762645ioc.120.1533909581427; Fri, 10 Aug 2018 06:59:41 -0700 (PDT) X-Received: by 2002:aca:de07:: with SMTP id v7-v6mr205302oig.5.1533909581262; Fri, 10 Aug 2018 06:59:41 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!4.us.feeder.erje.net!feeder.erje.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!g24-v6no659287iti.0!news-out.google.com!g5-v6ni513iti.0!nntp.google.com!g24-v6no659286iti.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 10 Aug 2018 06:59:40 -0700 (PDT) In-Reply-To: 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> <60ddd5ae-57e1-45e8-929c-302fabaa24ef@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <96424a63-d811-4ade-88db-258f3febe60a@googlegroups.com> Subject: Re: SI Units Checked and Unchecked From: "Dan'l Miller" Injection-Date: Fri, 10 Aug 2018 13:59:41 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:54124 Date: 2018-08-10T06:59:40-07:00 List-Id: On Friday, August 10, 2018 at 1:45:47 AM UTC-5, Dmitry A. Kazakov wrote: > 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. in today's Ada. > 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