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-13 13:56:20 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!ppp-1-26.cvx4.telinco.NET!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Re: Dimensionality Checking (Ada 20XX) Date: Thu, 13 Dec 2001 19:52:03 -0000 Message-ID: <9vb860$e8rbj$1@ID-25716.news.dfncis.de> References: <11bf7180.0112070815.2625851b@posting.google.com> <9v0crt$bo2bi$1@ID-25716.news.dfncis.de> <9v37rs$cdmva$1@ID-25716.news.dfncis.de> <9v5loh$d5aki$1@ID-25716.news.dfncis.de> <9v6iv7$dcrbf$2@ID-25716.news.dfncis.de> NNTP-Posting-Host: ppp-1-26.cvx4.telinco.net (212.1.148.26) X-Trace: fu-berlin.de 1008280578 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:17880 Date: 2001-12-13T19:52:03+00:00 List-Id: "Stephen Leake" wrote in message news:upu5kjzgq.fsf@gsfc.nasa.gov... > Well, V is _not_ a vector of "angles", it is a vector of "Cartesian > positions". I guess you should do: > > V := F (...); > M := Cartesian_Position (V); > > Where Cartesian_Position does some scaling. > > But I repeat, I see no advantage here. I can easily and efficiently > define F to return a vector of meters. Hah! That's a comment that O will touch upon further down. > > I'm not arguing about that. It would be nice to provide the facility for > > floating point numbers, I don't deny it. I just think it would be hard, > > that's all. But if it's needed, then it's needed. > > Huh? Why would it be harder for float than fixed? I've mulled this one over. This issue has a lot of subtleties. I think the basic answer is that floating point types could also have units. However, questions remain in my mind as to the actual usage of such types. I won't go through the whole thing in laborious detail here, but the essence is that unit-specific floating point types may need (or tend to make use of) the ability to specify and check units dynamically. E.g.: ... Read(Datafile,Scaling); declare Length_Unit: constant Unit_Type := (Length_Dim,Scaling); type Length is digits 5 unit Length_Unit; begin while not End_of_File(Datafile) loop Read(Datafile,V.X); Read(Datafile,V.Y); Read(Datafile,V.Z); ... The point of this example is that the scaling factor of the unit to be used for the floating point type Length is read in (dynamically) from the front of a data file, enabling the units of the data in the file to be chosen (feet, meters, whatever). This is acceptable, because the type (being floating point) has relative error. The dimensions, Length_Dim, are still static, but the unit, Length_Unit, is not. Would compilers still be able to perform the dimension checking at compile-time? It is this sort of question that complicates the issue a bit. > > Many (most?) of the required inter-type operations will be provided as > > predefined operations. This in itself is not a big change, since Ada 95 > > already provides it! > > Um, no. In Ada 95, I can do: > > type Meters is digits ...; > type Seconds is digits ...; > type Meters_Per_Second is digits ...; > > Ada 95 does _not_ define the following, which is needed: > > function "/" (Left : in Meters; Right in Seconds) return > Meters_Per_Second; It does if you use fixed point instead of floating point types. This was one of the reasons why I felt it would be harder to add units to floating point types. > If X is to be passed to a transcendental function, yes, it must be > dimensionless. But that's _not_ what I'm doing with X! I am _defining_ > the position of the end of a robot arm to be V == (x, y, z). By > _definition_, x, y, and z are in meters. As such, it is _meaningless_ > to pass x to a transcendental function. That's fine; the mathematical > meaninglessness simply reflects a physical meaninglessness. There is > no meaninful physical operation that corresponds to Sin (meters). So why did you give it as an example? > > -- > -- Stephe -- Best wishes, Nick Roberts