comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: SI Units Checked and Unchecked
Date: Thu, 9 Aug 2018 17:51:57 +0200
Date: 2018-08-09T17:51:57+02:00	[thread overview]
Message-ID: <pkhnur$fp9$1@gioia.aioe.org> (raw)
In-Reply-To: aea11f39-b169-4490-a4c7-1306ecbe8e2d@googlegroups.com

On 2018-08-09 17:03, Dan'l Miller wrote:

> 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.

No, I am speaking about a widget that checks and enforces measurement 
units. If you look how GUI widgets are constructed you would notice 
adjustment objects, events to propagate, properties to set and query, 
MVC and dozens of other things connecting the widget to the world around 
it, all dealing with measurement units. There is no way anybody could 
design this with generics or statically typed.

It can be statically constrained though, in some few cases, because 
widgets are customary stored and restored. There might be some limited 
cases with all static layouts in avionics or medical applications, these 
are an exception from the common rule.

And note that speed and pressure are measured in dozens different units. 
One of the requirements of sane design is that all compatible units were 
allowed. E.g. an adjustment object in kPa should work with a barograph 
indicating mm Hg. And I don't remember a single customer who ever wanted 
his HMI showing speed in SI's m/s.

>> 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?)

The issues I meant are necessary precondition to make a reasonable AI on 
dimensioned types.

As an example of such an issue consider the problem of constraint 
propagation:

    type Dimensioned is ...;
    type Dimensioned_Array (Positive range <>) of Dimensioned;

Here we want the measurement unit constraint of the array to propagate 
to its elements. And of course we don't want the elements in the array 
to keep their constraints as they must all be coming from the array (or 
a container in general case). Ada type system lacks such mechanism. Note 
that this problem is larger than the problem of measurement units. 
Actually, if the type system were fixed no specific AI might be required 
at all.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  reply	other threads:[~2018-08-09 15:51 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
2018-08-09 15:51       ` Dmitry A. Kazakov [this message]
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