From: "Dan'l Miller" <optikos@verizon.net>
Subject: Re: SI Units Checked and Unchecked
Date: Thu, 9 Aug 2018 08:03:29 -0700 (PDT)
Date: 2018-08-09T08:03:29-07:00 [thread overview]
Message-ID: <aea11f39-b169-4490-a4c7-1306ecbe8e2d@googlegroups.com> (raw)
In-Reply-To: <pkhhqo$4d8$1@gioia.aioe.org>
On Thursday, August 9, 2018 at 9:07:23 AM UTC-5, Dmitry A. Kazakov wrote:
> On 2018-08-09 15:47, Dan'l Miller wrote:
>
> > Shouldn't the •entire• point of a units-of-measurement library (or feature of language) be
> > compile-time errors, not run-time exceptions/errors.
>
> No, because in most cases the unit is unknown.
No, apparently in “most cases” you are writing either some sort of toy calculator or some sort of excessively over-generalized library marketed to too-wide of an audience. Apparently in “most cases” you are not writing the •app-domain• controls for actual hardware deployed into an actual physical environment, where the units of measure are a settled topic, not pulled out of thin air on a changing whim.
Well, factually incorrect opinions like yours above would be the reason for losses similar to the Mars Climate Orbiter in the future, even if coded is so-called ‘safety-critical’ Ada.
http://www.cnn.com/TECH/space/9909/30/mars.metric.02
Thinking that units of measure is a run-time choice (instead of an end-to-end agreed-upon engineering-time choice) would cause other such epic engineering failures for no good reason other than units of measure not being strongly-typed in the programming language.
> Consider a widget library
Yep, library.
> with instruments indicating dimensioned values, dimensioned calculator,
> serialization of dimensioned data etc.
So, Dmitry, you are making the mistake of excessive reuse in the app-domain of an unfinished library. Sure, at some deep level in the library, there can be a generic gauge that skeuomorphically represents a swinging black needle on a white circle that has no idea whether it is measuring pressure or amperes or volts or speed. But at the intended user-interface facade of the library, there should be:
1) a strongly-typed gauge for amperes,
2) a separate strongly-typed gauge for pressure,
3) a separate strongly-typed gauge for volts,
4) a separate strongly-typed gauge for speed,
and so forth that are wrappers around the one shared white circle with swinging black needle as the generic unitless-clueless(-at-engineering-/compile-time) gauge of which you speak.
> What is necessary but not sufficient is language support for handling
> statically known constraints using compile-time static operations and
> removing statically known discriminants from the representation.
>
> Note a direct analogy with classes for scalar types. Type tag is in
> essence just a discriminant. For some types we want static discriminants
> and other constraints removed.
>
> > I would be interested in a summary (or even better, an AI) that itemizes all the core-language
> > obstacles in currently-standardized Ada to moving all the incompatible usages of units to be
> > compile-time errors instead of raising exceptions.
>
> The Ada type system is not capable to handle dimensioned types. I posted
> a list of requirements for a dimensioned types support some years ago here.
>
> There are lots of language issues to resolve first before approaching
> dimensioned types.
As strongly-typed as Ada is, we often yearn for a more-Ada-than-Ada level of an even stronger-typed Ada. Even you. Even for compile-time-enforced strongly-typed units of measure. (Or else why would you expend that analysis's effort in the first place?)
next prev parent reply other threads:[~2018-08-09 15:03 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-09 12:44 SI Units Checked and Unchecked AdaMagica
2018-08-09 13:47 ` Dan'l Miller
2018-08-09 14:07 ` Dmitry A. Kazakov
2018-08-09 15:03 ` Dan'l Miller [this message]
2018-08-09 15:51 ` Dmitry A. Kazakov
2018-08-09 17:32 ` Dan'l Miller
2018-08-09 19:42 ` Dmitry A. Kazakov
2018-08-09 22:12 ` Dan'l Miller
2018-08-10 6:45 ` Dmitry A. Kazakov
2018-08-10 13:59 ` Dan'l Miller
2018-08-10 14:50 ` Dmitry A. Kazakov
2018-08-10 17:04 ` Dan'l Miller
2018-08-10 17:34 ` Dmitry A. Kazakov
2018-08-11 4:42 ` Paul Rubin
2018-08-11 5:46 ` Dmitry A. Kazakov
2018-08-11 19:57 ` Paul Rubin
2018-08-11 21:01 ` Dmitry A. Kazakov
2018-08-09 18:47 ` Paul Rubin
2018-08-09 19:13 ` Dan'l Miller
2018-08-09 14:31 ` AdaMagica
2018-08-09 15:19 ` Dan'l Miller
2018-08-09 16:07 ` Jeffrey R. Carter
2018-08-09 17:41 ` AdaMagica
2018-08-09 20:34 ` Jeffrey R. Carter
2018-08-10 9:13 ` AdaMagica
2018-08-10 20:20 ` Jeffrey R. Carter
2018-08-13 8:57 ` AdaMagica
2018-08-20 17:55 ` AdaMagica
2019-09-04 14:20 ` Shark8
2019-09-04 17:11 ` AdaMagica
2019-09-06 21:01 ` Shark8
2020-08-13 12:24 ` SI Units Checked and Unchecked - Completela overhauled version AdaMagica
-- strict thread matches above, loose matches on Subject: below --
2003-02-05 7:03 SI Units Checked and Unchecked Grein, Christoph
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox