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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fe9ec916c5bbbd59 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-13 13:56:22 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.hanau.net!news-fra1.dfn.de!fu-berlin.de!uni-berlin.de!ppp-1-26.cvx4.telinco.NET!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Re: Consider her way -- Re: Dimensionality Checking Date: Thu, 13 Dec 2001 21:08:42 -0000 Message-ID: <9vb863$e8rbj$2@ID-25716.news.dfncis.de> References: NNTP-Posting-Host: ppp-1-26.cvx4.telinco.net (212.1.148.26) X-Trace: fu-berlin.de 1008280579 14970227 212.1.148.26 (16 [25716]) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Xref: archiver1.google.com comp.lang.ada:17881 Date: 2001-12-13T21:08:42+00:00 List-Id: "Alexandre E. Kopilovitch" wrote in message news:mailman.1008097622.26173.comp.lang.ada@ada.eu.org... > Recent discussion about the dimensions/unit analysis seems to me... well, not > directed by the spirit of the Ada language. As far as I understand, all > participants of the discussion presume that if the dimensional/unit analysis > should be done for an Ada program then it must be performed entirely with the > facilities of Ada language itself. I think that that assumption is plain wrong. > ... The reason for proposing a unit (or dimension) checking scheme as an extension to the Ada language, is so that the portability and other benefits of standardisation will then apply. My reasons for associating a unit with a type rather than a subtype is to do with explicit conversion between values of the same dimensionality but different units. In Ada, values of the same subtype can be used interchangeably in expressions; the only place where the subtype matters is where a variable is updated, in which case the new value is checked to ensure it is compatible with the variable's subtype. This is a basic priciple in Ada, and I did't want to change it. With scalar values of different types, the only way to use a value, X1 say, of one type, T1 say, in a place where another type, T2 say, is expected, is with an explict conversion T2(X1). The converse conversion T1(X2) is always possible, and a view conversion implies two conversions, one in each direction. This fits perfectly with the conversion between two values of different units (of the same dimensionality), which is assumed to be achievable by multiplication by a certain factor: the conversion is always bidirectional (the converse conversion is achieved by multiplication by the inverse of the factor). Hence, it works neatly to associate a unit with a type. -- Best wishes, Nick Roberts