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,cc4f25d878383cc X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-09 19:36:07 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!fu-berlin.de!uni-berlin.de!ppp-1-20.cvx5.telinco.NET!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Re: Dimensionality Checking (Ada 20XX) Date: Mon, 10 Dec 2001 03:33:18 -0000 Message-ID: <9v1aj3$bqlh0$1@ID-25716.news.dfncis.de> References: <11bf7180.0112070815.2625851b@posting.google.com> <9v0crt$bo2bi$1@ID-25716.news.dfncis.de> <3C141540.96E5EB0D@worldnet.att.net> NNTP-Posting-Host: ppp-1-20.cvx5.telinco.net (212.1.152.20) X-Trace: fu-berlin.de 1007955364 12408352 212.1.152.20 (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:17663 Date: 2001-12-10T03:33:18+00:00 List-Id: "James Rogers" wrote in message news:3C141540.96E5EB0D@worldnet.att.net... > Mark Lundquist wrote: > > > > Would you not prefer a solution in which no particular set of units was > > built in to the core language? That is, I think it would be fine if the > > standard library had a package Ada.SI_Units or whatever, written in ordinary > > Ada 20xx (a unit-aware language), just to save everyone the trouble of > > writing it themselves, but I don't think that the core language itself > > should have any intrinsic units. Please comment! > > I agree. The basic language capability of units should not declare any > particular set of units. > > The SI_Units package proposed can be useful, but also terribly limiting. > The chosen units would be inappropriate for calculations dealing with > submolecular physics, or astronomy. Neither of these fields should be > systematically ignored by Ada. Perhaps I did not make it clear enough, but the user can declare her own units using the predefined units as a base, e.g.: Parsec: constant Unit_Type := Ada.Units.Meter * 3.01e16; Angstrom: constant Unit_Type := Ada.Units.Meter * 10.0e-10; User-defined dimensions could be accommodated by making the Ada.Units package generic, and maybe renaming it, e.g.: generic type Dimension is (<>); package Ada.Dimension_Checking is type Dimensionality is array (Dimension) of Integer; type Scaling_Factor is digits ...; -- highly accurate type Unit_Type is record Is_Unitless: Boolean := True; Dim: Dimensionality := (others => 0); Scaling: Scaling_Factor := 1.0; end record; Unitless: constant Unit_Type := (Is_Unitless => True, Scaling => 1.0); -- functions "*", "/", and "**" end Ada.Dimension_Checking; There might then be: package Ada.ISO_Units is type ISO_Dimension is (Mass, Length, Time, Temperature, Matter, Current); package ISO_Dimension_Checking is new Ada.Dimension_Checking(ISO_Dimension); subtype Unit_Type is ISO_Dimension_Checking.Unit_Type; Meter: constant Unit_Type := (Is_Unitless => False, Dim => (Length => 1, others => 0), Scaling => 1.0); -- etc. end Ada.ISO_Units; This complicates things for the compiler, so it would be nice if it were not necessary. -- Best wishes, Nick Roberts